diff options
author | Chris Withers <chris@withers.org> | 2020-01-13 12:42:08 +0000 |
---|---|---|
committer | Chris Withers <chris@withers.org> | 2020-01-13 18:09:46 +0000 |
commit | 389e48e48edca1a04f4b5a9fa29d434669b4d2e8 (patch) | |
tree | f7102e0d08446d9f21a1b1943859bbb96039ac3c | |
parent | b81f7b60f4478b83f8614db4263ab7e4b2593783 (diff) | |
download | mock-389e48e48edca1a04f4b5a9fa29d434669b4d2e8.tar.gz |
fix imports
-rw-r--r-- | mock/tests/testasync.py | 4 | ||||
-rw-r--r-- | mock/tests/testcallable.py | 7 | ||||
-rw-r--r-- | mock/tests/testhelpers.py | 8 | ||||
-rw-r--r-- | mock/tests/testmagicmethods.py | 4 | ||||
-rw-r--r-- | mock/tests/testmock.py | 10 | ||||
-rw-r--r-- | mock/tests/testpatch.py | 37 | ||||
-rw-r--r-- | mock/tests/testsealable.py | 2 | ||||
-rw-r--r-- | mock/tests/testsentinel.py | 2 | ||||
-rw-r--r-- | mock/tests/testwith.py | 4 |
9 files changed, 38 insertions, 40 deletions
diff --git a/mock/tests/testasync.py b/mock/tests/testasync.py index fa906e4..1910fba 100644 --- a/mock/tests/testasync.py +++ b/mock/tests/testasync.py @@ -2,8 +2,8 @@ import asyncio import inspect import unittest -from unittest.mock import (call, AsyncMock, patch, MagicMock, create_autospec, - _AwaitEvent) +from mock import call, AsyncMock, patch, MagicMock, create_autospec +from mock.mock import _AwaitEvent def tearDownModule(): diff --git a/mock/tests/testcallable.py b/mock/tests/testcallable.py index 5eadc00..41715ed 100644 --- a/mock/tests/testcallable.py +++ b/mock/tests/testcallable.py @@ -3,14 +3,13 @@ # http://www.voidspace.org.uk/python/mock/ import unittest -from unittest.test.testmock.support import is_instance, X, SomeClass +from mock.tests.support import is_instance, X, SomeClass -from unittest.mock import ( +from mock import ( Mock, MagicMock, NonCallableMagicMock, NonCallableMock, patch, create_autospec, - CallableMixin ) - +from mock.mock import CallableMixin class TestCallable(unittest.TestCase): diff --git a/mock/tests/testhelpers.py b/mock/tests/testhelpers.py index 301bca4..c58e55a 100644 --- a/mock/tests/testhelpers.py +++ b/mock/tests/testhelpers.py @@ -3,10 +3,11 @@ import time import types import unittest -from unittest.mock import ( - call, _Call, create_autospec, MagicMock, - Mock, ANY, _CallList, patch, PropertyMock, _callable +from mock import ( + call, create_autospec, MagicMock, + Mock, ANY, patch, PropertyMock ) +from mock.mock import _Call, _CallList, _callable from datetime import datetime from functools import partial @@ -17,7 +18,6 @@ class SomeClass(object): def three(self, a=None): pass - class AnyTest(unittest.TestCase): def test_any(self): diff --git a/mock/tests/testmagicmethods.py b/mock/tests/testmagicmethods.py index 130a339..fdb6f19 100644 --- a/mock/tests/testmagicmethods.py +++ b/mock/tests/testmagicmethods.py @@ -2,8 +2,8 @@ import math import unittest import os import sys -from unittest.mock import Mock, MagicMock, _magics - +from mock import Mock, MagicMock +from mock.mock import _magics class TestMockingMagicMethods(unittest.TestCase): diff --git a/mock/tests/testmock.py b/mock/tests/testmock.py index 0f30bcc..8a2f0e7 100644 --- a/mock/tests/testmock.py +++ b/mock/tests/testmock.py @@ -4,14 +4,14 @@ import sys import tempfile import unittest -from unittest.test.testmock.support import is_instance -from unittest import mock -from unittest.mock import ( +from mock.tests.support import is_instance +from mock import ( call, DEFAULT, patch, sentinel, MagicMock, Mock, NonCallableMock, - NonCallableMagicMock, AsyncMock, _Call, _CallList, - create_autospec + NonCallableMagicMock, AsyncMock, + create_autospec, mock ) +from mock.mock import _Call, _CallList class Iter(object): diff --git a/mock/tests/testpatch.py b/mock/tests/testpatch.py index 27914a9..15b3068 100644 --- a/mock/tests/testpatch.py +++ b/mock/tests/testpatch.py @@ -6,16 +6,16 @@ import os import sys import unittest -from unittest.test.testmock import support -from unittest.test.testmock.support import SomeClass, is_instance +from mock.tests import support +from mock.tests.support import SomeClass, is_instance from test.test_importlib.util import uncache -from unittest.mock import ( - NonCallableMock, CallableMixin, sentinel, - MagicMock, Mock, NonCallableMagicMock, patch, _patch, - DEFAULT, call, _get_target +from mock import ( + NonCallableMock, sentinel, + MagicMock, Mock, NonCallableMagicMock, patch, + DEFAULT, call ) - +from mock.mock import CallableMixin, _patch, _get_target builtin_string = 'builtins' @@ -664,7 +664,7 @@ class PatchTest(unittest.TestCase): # the new dictionary during function call original = support.target.copy() - @patch.dict('unittest.test.testmock.support.target', {'bar': 'BAR'}) + @patch.dict('mock.tests.support.target', {'bar': 'BAR'}) def test(): self.assertEqual(support.target, {'foo': 'BAZ', 'bar': 'BAR'}) @@ -1540,7 +1540,7 @@ class PatchTest(unittest.TestCase): self.assertEqual(foo.fish, 'tasty') - @patch('unittest.mock.patch.TEST_PREFIX', 'foo') + @patch('mock.patch.TEST_PREFIX', 'foo') def test_patch_test_prefix(self): class Foo(object): thing = 'original' @@ -1563,7 +1563,7 @@ class PatchTest(unittest.TestCase): self.assertEqual(foo.test_two(), 'original') - @patch('unittest.mock.patch.TEST_PREFIX', 'bar') + @patch('mock.patch.TEST_PREFIX', 'bar') def test_patch_dict_test_prefix(self): class Foo(object): def bar_one(self): @@ -1601,7 +1601,7 @@ class PatchTest(unittest.TestCase): def test_patch_nested_autospec_repr(self): - with patch('unittest.test.testmock.support', autospec=True) as m: + with patch('mock.tests.support', autospec=True) as m: self.assertIn(" name='support.SomeClass.wibble()'", repr(m.SomeClass.wibble())) self.assertIn(" name='support.SomeClass().wibble()'", @@ -1818,7 +1818,7 @@ class PatchTest(unittest.TestCase): with patch.object(foo, '__module__', "testpatch2"): self.assertEqual(foo.__module__, "testpatch2") - self.assertEqual(foo.__module__, 'unittest.test.testmock.testpatch') + self.assertEqual(foo.__module__, 'mock.tests.testpatch') with patch.object(foo, '__annotations__', dict([('s', 1, )])): self.assertEqual(foo.__annotations__, dict([('s', 1, )])) @@ -1834,16 +1834,15 @@ class PatchTest(unittest.TestCase): # This exercises the AttributeError branch of _dot_lookup. # make sure it's there - import unittest.test.testmock.support + import mock.tests.support # now make sure it's not: with patch.dict('sys.modules'): - del sys.modules['unittest.test.testmock.support'] - del sys.modules['unittest.test.testmock'] - del sys.modules['unittest.test'] - del sys.modules['unittest'] + del sys.modules['mock.tests.support'] + del sys.modules['mock.tests'] + del sys.modules['mock'] # now make sure we can patch based on a dotted path: - @patch('unittest.test.testmock.support.X') + @patch('mock.tests.support.X') def test(mock): pass test() @@ -1855,7 +1854,7 @@ class PatchTest(unittest.TestCase): def test_cant_set_kwargs_when_passing_a_mock(self): - @patch('unittest.test.testmock.support.X', new=object(), x=1) + @patch('mock.tests.support.X', new=object(), x=1) def test(): pass with self.assertRaises(TypeError): test() diff --git a/mock/tests/testsealable.py b/mock/tests/testsealable.py index 59f5233..63a8541 100644 --- a/mock/tests/testsealable.py +++ b/mock/tests/testsealable.py @@ -1,5 +1,5 @@ import unittest -from unittest import mock +import mock class SampleObject: diff --git a/mock/tests/testsentinel.py b/mock/tests/testsentinel.py index de53509..5666434 100644 --- a/mock/tests/testsentinel.py +++ b/mock/tests/testsentinel.py @@ -1,7 +1,7 @@ import unittest import copy import pickle -from unittest.mock import sentinel, DEFAULT +from mock import sentinel, DEFAULT class SentinelTest(unittest.TestCase): diff --git a/mock/tests/testwith.py b/mock/tests/testwith.py index 42ebf38..825387b 100644 --- a/mock/tests/testwith.py +++ b/mock/tests/testwith.py @@ -1,8 +1,8 @@ import unittest from warnings import catch_warnings -from unittest.test.testmock.support import is_instance -from unittest.mock import MagicMock, Mock, patch, sentinel, mock_open, call +from mock.tests.support import is_instance +from mock import MagicMock, Mock, patch, sentinel, mock_open, call |