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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 10 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_configparser.py ('k') | Lib/test/test_crypt.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 import copyreg 1 import copyreg
2 import unittest 2 import unittest
3 3
4 from test import support 4 from test import support
5 from test.pickletester import ExtensionSaver 5 from test.pickletester import ExtensionSaver
6 6
7 class C: 7 class C:
8 pass 8 pass
9 9
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 def test_extension_registry(self): 45 def test_extension_registry(self):
46 mod, func, code = 'junk1 ', ' junk2', 0xabcd 46 mod, func, code = 'junk1 ', ' junk2', 0xabcd
47 e = ExtensionSaver(code) 47 e = ExtensionSaver(code)
48 try: 48 try:
49 # Shouldn't be in registry now. 49 # Shouldn't be in registry now.
50 self.assertRaises(ValueError, copyreg.remove_extension, 50 self.assertRaises(ValueError, copyreg.remove_extension,
51 mod, func, code) 51 mod, func, code)
52 copyreg.add_extension(mod, func, code) 52 copyreg.add_extension(mod, func, code)
53 # Should be in the registry. 53 # Should be in the registry.
54 self.assertTrue(copyreg._extension_registry[mod, func] == code) 54 self.assertEqual(copyreg._extension_registry[mod, func], code)
55 self.assertTrue(copyreg._inverted_registry[code] == (mod, func)) 55 self.assertEqual(copyreg._inverted_registry[code], (mod, func))
56 # Shouldn't be in the cache. 56 # Shouldn't be in the cache.
57 self.assertNotIn(code, copyreg._extension_cache) 57 self.assertNotIn(code, copyreg._extension_cache)
58 # Redundant registration should be OK. 58 # Redundant registration should be OK.
59 copyreg.add_extension(mod, func, code) # shouldn't blow up 59 copyreg.add_extension(mod, func, code) # shouldn't blow up
60 # Conflicting code. 60 # Conflicting code.
61 self.assertRaises(ValueError, copyreg.add_extension, 61 self.assertRaises(ValueError, copyreg.add_extension,
62 mod, func, code + 1) 62 mod, func, code + 1)
63 self.assertRaises(ValueError, copyreg.remove_extension, 63 self.assertRaises(ValueError, copyreg.remove_extension,
64 mod, func, code + 1) 64 mod, func, code + 1)
65 # Conflicting module name. 65 # Conflicting module name.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 result.sort() 112 result.sort()
113 self.assertEqual(result, expected) 113 self.assertEqual(result, expected)
114 114
115 115
116 def test_main(): 116 def test_main():
117 support.run_unittest(CopyRegTestCase) 117 support.run_unittest(CopyRegTestCase)
118 118
119 119
120 if __name__ == "__main__": 120 if __name__ == "__main__":
121 test_main() 121 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_configparser.py ('k') | Lib/test/test_crypt.py » ('j') | no next file with comments »

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