def test_mock(self): path = '/tmp/thisfiledefinitely/doesntexist' assert(not os.path.exists(path)) mockit.mock(os.path, 'exists') os.path.exists._mock.default_return_value = True assert(os.path.exists(path)) old_stat = os.stat mockit.mock(os, 'stat') os.stat = old_stat mockit.unmock_all() assert(not os.path.exists(path))
def tearDown(self): mockit.unmock_all() return unittest.TestCase.tearDown(self)