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