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

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

Issue 25958: Implicit ABCs have no means of "anti-registration"
Patch Set: Created 3 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/test_binop.py ('k') | Lib/test/test_bytes.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 # Test properties of bool promised by PEP 285 1 # Test properties of bool promised by PEP 285
2 2
3 import unittest 3 import unittest
4 from test import support 4 from test import support
5 5
6 import os 6 import os
7 7
8 class BoolTest(unittest.TestCase): 8 class BoolTest(unittest.TestCase):
9 9
10 def test_subclass(self): 10 def test_subclass(self):
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 class A: 325 class A:
326 def __len__(self): 326 def __len__(self):
327 return badval 327 return badval
328 try: 328 try:
329 bool(A()) 329 bool(A())
330 except (Exception) as e_bool: 330 except (Exception) as e_bool:
331 try: 331 try:
332 len(A()) 332 len(A())
333 except (Exception) as e_len: 333 except (Exception) as e_len:
334 self.assertEqual(str(e_bool), str(e_len)) 334 self.assertEqual(str(e_bool), str(e_len))
335
336 def test_blocked(self):
337 class A:
338 __bool__ = None
339 self.assertRaises(TypeError, bool, A())
340
341 class B:
342 def __len__(self):
343 return 10
344 __bool__ = None
345 self.assertRaises(TypeError, bool, B())
335 346
336 def test_real_and_imag(self): 347 def test_real_and_imag(self):
337 self.assertEqual(True.real, 1) 348 self.assertEqual(True.real, 1)
338 self.assertEqual(True.imag, 0) 349 self.assertEqual(True.imag, 0)
339 self.assertIs(type(True.real), int) 350 self.assertIs(type(True.real), int)
340 self.assertIs(type(True.imag), int) 351 self.assertIs(type(True.imag), int)
341 self.assertEqual(False.real, 0) 352 self.assertEqual(False.real, 0)
342 self.assertEqual(False.imag, 0) 353 self.assertEqual(False.imag, 0)
343 self.assertIs(type(False.real), int) 354 self.assertIs(type(False.real), int)
344 self.assertIs(type(False.imag), int) 355 self.assertIs(type(False.imag), int)
345 356
346 def test_main(): 357 def test_main():
347 support.run_unittest(BoolTest) 358 support.run_unittest(BoolTest)
348 359
349 if __name__ == "__main__": 360 if __name__ == "__main__":
350 test_main() 361 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_binop.py ('k') | Lib/test/test_bytes.py » ('j') | no next file with comments »

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