Skip to content

Commit 8e0a2ac

Browse files
authored
Merge pull request #116 from kaste/unstub-str
2 parents 39ed40e + ba4ddcf commit 8e0a2ac

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

mockito/mockito.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ def unstub(*objs):
360360

361361
if objs:
362362
for obj in objs:
363+
if isinstance(obj, str):
364+
obj = get_obj(obj)
363365
mock_registry.unstub(obj)
364366
else:
365367
mock_registry.unstub_all()

tests/modulefunctions_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ def testUnstubs(self):
3636
unstub()
3737
self.assertEqual(False, os.path.exists("test"))
3838

39+
def testUnstubsByDottedPath(self):
40+
when("os.path").exists("test").thenReturn(True)
41+
42+
self.assertEqual(True, os.path.exists("test"))
43+
44+
unstub("os.path")
45+
46+
self.assertEqual(False, os.path.exists("test"))
47+
3948
def testStubs(self):
4049
when(os.path).exists("test").thenReturn(True)
4150

0 commit comments

Comments
 (0)