def test_unpatchAll_expectContextManagerNotInvoked(self): petour.patch('petourtest.sut_', free_func_names=['foobar']) ctx = Counter() petour.unpatch_all() foobar() sut_.foobar() self.assertEqual(0, ctx.count)
def test_unpatchAll_expectContextManagerNotInvoked(self): petour.patch('petourtest.sut_', class_dot_methods=['FooBar.kls_count']) ctx = Counter() petour.unpatch_all() FooBar.kls_count(11) sut_.FooBar.kls_count(111) self.assertEqual(0, ctx.count)
def test_unpatchAfterThreadCreation(self): t = threading.Thread(target=foobar) ctx = Counter() petour.patch('petourtest.sut_', free_func_names=['foobar'], ctx=ctx) petour.unpatch_all() t.start() t.join() self.assertEqual(0, ctx.count)
def test_expectFreeVarsPreserved(self): ctx = Counter() petour.patch('petourtest.sut_', free_func_names=['func_freevars'], ctx=ctx) sut_.func_freevars() sut_.func_freevars() self.assertEqual(3, sut_.func_freevars()) petour.unpatch_all() self.assertEqual(4, sut_.func_freevars()) self.assertEqual(3, ctx.count)
def test_patchTwice_expectNoSideEffect(self): petour.patch('petourtest.sut_', free_func_names=['foobar']) petour.patch('petourtest.sut_', free_func_names=['foobar']) self.assertEqual(1, len(petour.petours())) self.assertEqual(1, foobar(1)) ctx = petour.context_manager('petourtest.sut_', 'foobar') self.assertTrue(ctx) petour.unpatch_all() self.assertEqual(0, len(petour.petours())) ctx = petour.context_manager('petourtest.sut_', 'foobar') self.assertFalse(ctx)
def test_patchTwice_expectNoSideEffect(self): petour.patch('petourtest.sut_', class_dot_methods=['FooBar.count']) petour.patch('petourtest.sut_', class_dot_methods=['FooBar.count']) self.assertEqual(1, len(petour.petours())) self.assertEqual(1, foobar(1)) ctx = petour.context_manager('petourtest.sut_', 'FooBar.count') self.assertTrue(ctx) petour.unpatch_all() self.assertEqual(0, len(petour.petours())) ctx = petour.context_manager('petourtest.sut_', 'FooBar.count') self.assertFalse(ctx)
def test_unpatchAll_expectNoPetourCount(self): petour.patch('petourtest.sut_', free_func_names=['foobar']) petour.unpatch_all() self.assertFalse(petour.petours())
def test_unpatchAll_expectNoPetourCount(self): petour.patch('petourtest.sut_', class_dot_methods=['FooBar.count']) petour.unpatch_all() self.assertFalse(petour.petours())
def tearDown(self): petour.unpatch_all()