Adding patch.stopall method to unittest.mock

This commit is contained in:
Michael Foord 2012-06-10 20:36:32 +01:00
parent bfcb42936b
commit f7c4158057
3 changed files with 44 additions and 4 deletions

View file

@ -1762,6 +1762,24 @@ class PatchTest(unittest.TestCase):
p.stop()
def test_patch_stopall(self):
unlink = os.unlink
chdir = os.chdir
path = os.path
patch('os.unlink', something).start()
patch('os.chdir', something_else).start()
@patch('os.path')
def patched(mock_path):
patch.stopall()
self.assertIs(os.path, mock_path)
self.assertIs(os.unlink, unlink)
self.assertIs(os.chdir, chdir)
patched()
self.assertIs(os.path, path)
if __name__ == '__main__':
unittest.main()