Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(6)

Side by Side Diff: Lib/test/test_abc.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 6 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/pickletester.py ('k') | Lib/test/test_argparse.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2007 Google, Inc. All Rights Reserved. 1 # Copyright 2007 Google, Inc. All Rights Reserved.
2 # Licensed to PSF under a Contributor Agreement. 2 # Licensed to PSF under a Contributor Agreement.
3 3
4 """Unit tests for abc.py.""" 4 """Unit tests for abc.py."""
5 5
6 import unittest 6 import unittest
7 from test import support 7 from test import support
8 8
9 import abc 9 import abc
10 from inspect import isabstract 10 from inspect import isabstract
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 self.assertIsInstance(c, A) 320 self.assertIsInstance(c, A)
321 self.assertIsInstance(c, (A,)) 321 self.assertIsInstance(c, (A,))
322 self.assertIs(C, A.register(C)) 322 self.assertIs(C, A.register(C))
323 323
324 def test_isinstance_invalidation(self): 324 def test_isinstance_invalidation(self):
325 class A(metaclass=abc.ABCMeta): 325 class A(metaclass=abc.ABCMeta):
326 pass 326 pass
327 class B: 327 class B:
328 pass 328 pass
329 b = B() 329 b = B()
330 self.assertFalse(isinstance(b, A)) 330 self.assertNotIsInstance(b, A)
331 self.assertFalse(isinstance(b, (A,))) 331 self.assertNotIsInstance(b, (A,))
332 A.register(B) 332 A.register(B)
333 self.assertTrue(isinstance(b, A)) 333 self.assertIsInstance(b, A)
334 self.assertTrue(isinstance(b, (A,))) 334 self.assertIsInstance(b, (A,))
335 335
336 def test_registration_builtins(self): 336 def test_registration_builtins(self):
337 class A(metaclass=abc.ABCMeta): 337 class A(metaclass=abc.ABCMeta):
338 pass 338 pass
339 A.register(int) 339 A.register(int)
340 self.assertIsInstance(42, A) 340 self.assertIsInstance(42, A)
341 self.assertIsInstance(42, (A,)) 341 self.assertIsInstance(42, (A,))
342 self.assertTrue(issubclass(int, A)) 342 self.assertTrue(issubclass(int, A))
343 self.assertTrue(issubclass(int, (A,))) 343 self.assertTrue(issubclass(int, (A,)))
344 class B(A): 344 class B(A):
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 C() 428 C()
429 self.assertEqual(B.counter, 1) 429 self.assertEqual(B.counter, 1)
430 430
431 431
432 def test_main(): 432 def test_main():
433 support.run_unittest(TestABC) 433 support.run_unittest(TestABC)
434 434
435 435
436 if __name__ == "__main__": 436 if __name__ == "__main__":
437 unittest.main() 437 unittest.main()
OLDNEW
« no previous file with comments | « Lib/test/pickletester.py ('k') | Lib/test/test_argparse.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+