Lines Matching defs:Test
9 from unittest.test.testmock import support
10 from unittest.test.testmock.support import SomeClass, is_instance
12 from test.test_importlib.util import uncache
40 # for use in the test
100 def test():
103 test()
113 def test():
116 test()
128 def test():
134 test()
145 def test():
150 test()
158 def test():
162 test()
168 def test():
179 # Test the patching and restoring works a second time
180 test()
190 def test():
193 test()
194 test()
202 def test():
205 test()
212 class Test(object):
216 @patch.object(Test, 'something')
217 def test(mock):
218 self.assertEqual(mock, Test.something,
219 "Mock not passed into test function")
223 test()
225 @patch.object(Test, 'something')
226 @patch.object(Test, 'something2')
227 def test(this1, this2, mock1, mock2):
232 self.assertEqual(mock1, Test.something2,
233 "Mock not passed into test function")
234 self.assertEqual(mock2, Test.something,
235 "Second Mock not passed into test function")
241 # A hack to test that new mocks are passed the second time
247 outerMock1, outerMock2 = test(sentinel.this1, sentinel.this2)
249 # Test that executing a second time creates new mocks
250 test(sentinel.this1, sentinel.this2)
255 def test(MockSomeClass):
260 test()
265 def test(MockAttribute):
272 test()
277 def test(MockSomeClass):
282 test()
287 def test(MockAttribute):
294 test()
298 # regression test for nested decorators
301 def test(MockSomeClass, MockOpen):
305 test()
310 def test(MockSomeClass):
317 test()
322 def test(MockSomeClass):
329 test()
334 def test(MockSomeClass):
343 test()
348 def test():
351 test()
357 def test():
360 test()
367 def test():
370 test()
382 def test():
385 test()
462 "non-test method patched")
484 "non-test method patched")
504 def test():
507 test()
518 def test():
523 test()
528 def test():
532 test()
537 def test():
541 test()
554 def test():
559 test()
564 def test():
568 test()
578 def test():
583 test()
588 def test():
591 test()
596 def test():
599 test()
612 def test():
617 test()
622 def test():
625 test()
647 def test():
650 test()
654 self.fail('NameError not raised by test')
661 def test():
664 test()
672 @patch.dict('unittest.test.testmock.support.target', {'bar': 'BAR'})
673 def test():
678 test()
729 def test(MockClass):
732 self.assertRaises(AttributeError, test)
735 def test(MockClass):
738 self.assertRaises(AttributeError, test)
740 def test(MockClass):
743 self.assertRaises(AttributeError, test)
746 def test(MockClass):
749 self.assertRaises(AttributeError, test)
754 def test(MockClass):
758 self.assertRaises(AttributeError, test)
813 class Test(object):
819 Test = patch.dict(d, {'foo': 'bar'}, clear=True)(Test)
822 test = Test()
824 test.test_first()
827 test.test_second()
830 test = Test()
832 test.test_first()
835 test.test_second()
849 def test():
851 test()
867 def test():
869 test()
971 test = patch(foo_name, autospec=True)(function)
973 mock = test()
975 # test patching a second time works
976 test()
979 test = patch.object(module, 'Foo', autospec=True)(function)
981 mock = test()
983 # test patching a second time works
984 test()
989 def test(mock):
1004 test()
1010 def test(mock_function):
1014 result = test()
1066 def test():
1069 test()
1211 test = self
1216 test.assertIsNot(Foo, original)
1217 test.assertIs(Foo, mock_foo)
1218 test.assertIsInstance(Foo, SomeClass)
1254 def test():
1259 test()
1273 def test(f, foo):
1281 test()
1299 def test(g):
1303 test()
1377 test = self
1385 test.assertIs(Foo, original_foo)
1386 test.assertIs(Foo.f, f)
1387 test.assertEqual(Foo.g, 3)
1388 test.assertIs(Foo.foo, foo)
1389 test.assertTrue(is_instance(f, MagicMock))
1390 test.assertTrue(is_instance(foo, MagicMock))
1577 def test():
1580 test()
1645 with patch('unittest.test.testmock.support', autospec=True) as m:
1713 def test(mock):
1720 self.assertRaises(RuntimeError, test)
1850 """TEST"""
1858 self.assertEqual(foo.__doc__, "TEST")
1862 self.assertEqual(foo.__module__, 'unittest.test.testmock.testpatch')