ยปCore Development>Code coverage>Lib/test/test_importlib/extension/test_case_sensitivity.py

Python code coverage for Lib/test/test_importlib/extension/test_case_sensitivity.py

#countcontent
1n/afrom importlib import _bootstrap_external
2n/afrom test import support
3n/aimport unittest
4n/a
5n/afrom .. import util
6n/a
7n/aimportlib = util.import_importlib('importlib')
8n/amachinery = util.import_importlib('importlib.machinery')
9n/a
10n/a
11n/a@unittest.skipIf(util.EXTENSIONS.filename is None, '_testcapi not available')
12n/a@util.case_insensitive_tests
13n/aclass ExtensionModuleCaseSensitivityTest(util.CASEOKTestBase):
14n/a
15n/a def find_module(self):
16n/a good_name = util.EXTENSIONS.name
17n/a bad_name = good_name.upper()
18n/a assert good_name != bad_name
19n/a finder = self.machinery.FileFinder(util.EXTENSIONS.path,
20n/a (self.machinery.ExtensionFileLoader,
21n/a self.machinery.EXTENSION_SUFFIXES))
22n/a return finder.find_module(bad_name)
23n/a
24n/a def test_case_sensitive(self):
25n/a with support.EnvironmentVarGuard() as env:
26n/a env.unset('PYTHONCASEOK')
27n/a self.caseok_env_changed(should_exist=False)
28n/a loader = self.find_module()
29n/a self.assertIsNone(loader)
30n/a
31n/a def test_case_insensitivity(self):
32n/a with support.EnvironmentVarGuard() as env:
33n/a env.set('PYTHONCASEOK', '1')
34n/a self.caseok_env_changed(should_exist=True)
35n/a loader = self.find_module()
36n/a self.assertTrue(hasattr(loader, 'load_module'))
37n/a
38n/a
39n/a(Frozen_ExtensionCaseSensitivity,
40n/a Source_ExtensionCaseSensitivity
41n/a ) = util.test_both(ExtensionModuleCaseSensitivityTest, importlib=importlib,
42n/a machinery=machinery)
43n/a
44n/a
45n/aif __name__ == '__main__':
46n/a unittest.main()