From 0139298786ca2355925d54ad333fa93db976cf04 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Tue, 13 Sep 2016 10:50:05 -0700 Subject: [PATCH] Have unittests import mock from ansible.compat so they work on py3 without mock installed from pypi --- test/units/cli/test_galaxy.py | 4 +--- test/units/module_utils/test_database.py | 3 ++- test/units/modules/core/test_apt.py | 4 ++-- test/units/plugins/connections/test_connection.py | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/test/units/cli/test_galaxy.py b/test/units/cli/test_galaxy.py index be9f8a5dad2..39f06f2ac6d 100644 --- a/test/units/cli/test_galaxy.py +++ b/test/units/cli/test_galaxy.py @@ -24,11 +24,9 @@ import shutil import tarfile import tempfile -from mock import patch - from ansible.compat.six import PY3 from ansible.compat.tests import unittest -from mock import patch, call +from ansible.compat.tests.mock import call, patch import ansible from ansible.errors import AnsibleError, AnsibleOptionsError diff --git a/test/units/module_utils/test_database.py b/test/units/module_utils/test_database.py index c8d66402970..bb9cb8b9d90 100644 --- a/test/units/module_utils/test_database.py +++ b/test/units/module_utils/test_database.py @@ -1,5 +1,4 @@ import collections -import mock import os import re @@ -24,6 +23,8 @@ except ImportError: else: excName = str(expected) raise AssertionError("%s not raised" % excName) +from ansible.compat.tests import mock + from ansible.module_utils.database import ( pg_quote_identifier, SQLParseError, diff --git a/test/units/modules/core/test_apt.py b/test/units/modules/core/test_apt.py index a5571db1ca3..49f73be1d62 100644 --- a/test/units/modules/core/test_apt.py +++ b/test/units/modules/core/test_apt.py @@ -1,9 +1,9 @@ import collections -import mock import os import sys -from ansible.compat.tests import unittest +from ansible.compat.tests import mock +from ansible.compat.tests import unittest try: from ansible.modules.core.packaging.os.apt import ( diff --git a/test/units/plugins/connections/test_connection.py b/test/units/plugins/connections/test_connection.py index 0e7f4da0a08..c34fce1d691 100644 --- a/test/units/plugins/connections/test_connection.py +++ b/test/units/plugins/connections/test_connection.py @@ -21,8 +21,7 @@ __metaclass__ = type from io import StringIO -import mock - +from ansible.compat.tests import mock from ansible.compat.tests import unittest from ansible.errors import AnsibleError from ansible.playbook.play_context import PlayContext