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

Side by Side Diff: Lib/test/test_importlib/builtin/test_loader.py

Issue 15836: unittest assertRaises should verify excClass is actually a BaseException class
Patch Set: Created 4 years, 4 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 | « no previous file | Lib/unittest/case.py » ('j') | Lib/unittest/case.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 from .. import abc 1 from .. import abc
2 from .. import util 2 from .. import util
3 3
4 machinery = util.import_importlib('importlib.machinery') 4 machinery = util.import_importlib('importlib.machinery')
5 5
6 import sys 6 import sys
7 import types 7 import types
8 import unittest 8 import unittest
9 9
10 @unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module' ) 10 @unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module' )
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 result = self.machinery.BuiltinImporter.is_package(util.BUILTINS.good_na me) 90 result = self.machinery.BuiltinImporter.is_package(util.BUILTINS.good_na me)
91 self.assertFalse(result) 91 self.assertFalse(result)
92 92
93 @unittest.skipIf(util.BUILTINS.bad_name is None, 'all modules are built in') 93 @unittest.skipIf(util.BUILTINS.bad_name is None, 'all modules are built in')
94 def test_not_builtin(self): 94 def test_not_builtin(self):
95 # Modules not built-in should raise ImportError. 95 # Modules not built-in should raise ImportError.
96 for meth_name in ('get_code', 'get_source', 'is_package'): 96 for meth_name in ('get_code', 'get_source', 'is_package'):
97 method = getattr(self.machinery.BuiltinImporter, meth_name) 97 method = getattr(self.machinery.BuiltinImporter, meth_name)
98 with self.assertRaises(ImportError) as cm: 98 with self.assertRaises(ImportError) as cm:
99 method(util.BUILTINS.bad_name) 99 method(util.BUILTINS.bad_name)
100 self.assertRaises(util.BUILTINS.bad_name)
101 100
102 101
103 (Frozen_InspectLoaderTests, 102 (Frozen_InspectLoaderTests,
104 Source_InspectLoaderTests 103 Source_InspectLoaderTests
105 ) = util.test_both(InspectLoaderTests, machinery=machinery) 104 ) = util.test_both(InspectLoaderTests, machinery=machinery)
106 105
107 106
108 if __name__ == '__main__': 107 if __name__ == '__main__':
109 unittest.main() 108 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | Lib/unittest/case.py » ('j') | Lib/unittest/case.py » ('J')

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