ยปCore Development>Code coverage>Lib/importlib/test/import_/test_api.py

Python code coverage for Lib/importlib/test/import_/test_api.py

#countcontent
1n/afrom . import util
2n/aimport unittest
3n/a
4n/a
5n/aclass APITest(unittest.TestCase):
6n/a
7n/a """Test API-specific details for __import__ (e.g. raising the right
8n/a exception when passing in an int for the module name)."""
9n/a
10n/a def test_name_requires_rparition(self):
11n/a # Raise TypeError if a non-string is passed in for the module name.
12n/a with self.assertRaises(TypeError):
13n/a util.import_(42)
14n/a
15n/a def test_negative_level(self):
16n/a # Raise ValueError when a negative level is specified.
17n/a # PEP 328 did away with sys.module None entries and the ambiguity of
18n/a # absolute/relative imports.
19n/a with self.assertRaises(ValueError):
20n/a util.import_('os', globals(), level=-1)
21n/a
22n/a
23n/adef test_main():
24n/a from test.support import run_unittest
25n/a run_unittest(APITest)
26n/a
27n/a
28n/aif __name__ == '__main__':
29n/a test_main()