Skip to content

Commit

Permalink
fixup: imports
Browse files Browse the repository at this point in the history
  • Loading branch information
cjw296 committed Jan 13, 2020
1 parent c8fa22f commit 8a7846d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
3 changes: 1 addition & 2 deletions mock/tests/testmock.py
Expand Up @@ -5,12 +5,11 @@

import unittest
from mock.tests.support import is_instance
import mock
from mock import (
call, DEFAULT, patch, sentinel,
MagicMock, Mock, NonCallableMock,
NonCallableMagicMock, AsyncMock,
create_autospec
create_autospec, mock
)
from mock.mock import _Call, _CallList

Expand Down
19 changes: 9 additions & 10 deletions mock/tests/testpatch.py
Expand Up @@ -664,7 +664,7 @@ def test_patch_dict_decorator_resolution(self):
# 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'})

Expand Down Expand Up @@ -1540,7 +1540,7 @@ def test():
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'
Expand All @@ -1563,7 +1563,7 @@ def test_two(self):
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):
Expand Down Expand Up @@ -1818,7 +1818,7 @@ def foo(x=0):

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, )]))
Expand All @@ -1837,13 +1837,12 @@ def test_dotted_but_module_not_loaded(self):
import unittest.test.testmock.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()
Expand All @@ -1855,7 +1854,7 @@ def test_invalid_target(self):


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()
Expand Down

0 comments on commit 8a7846d

Please sign in to comment.