diff options
author | Brett Cannon <brett@python.org> | 2016-07-16 17:44:13 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2016-07-16 17:44:13 (GMT) |
commit | 7ca63cb7cc0ea962f40559ba57f767e38d7f1af7 (patch) | |
tree | b92cd20d63e51652b1324428ca591ff5e88a301b /Lib/test | |
parent | 702b0460d20fa699c1c703e00bcc93243e3020a1 (diff) | |
download | cpython-7ca63cb7cc0ea962f40559ba57f767e38d7f1af7.zip cpython-7ca63cb7cc0ea962f40559ba57f767e38d7f1af7.tar.gz cpython-7ca63cb7cc0ea962f40559ba57f767e38d7f1af7.tar.bz2 |
Fix regressions introduced by fixes for issue #27083.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_importlib/extension/test_case_sensitivity.py | 14 | ||||
-rw-r--r-- | Lib/test/test_importlib/source/test_case_sensitivity.py | 13 | ||||
-rw-r--r-- | Lib/test/test_importlib/util.py | 9 |
3 files changed, 18 insertions, 18 deletions
diff --git a/Lib/test/test_importlib/extension/test_case_sensitivity.py b/Lib/test/test_importlib/extension/test_case_sensitivity.py index 706c3e4..c112ca7 100644 --- a/Lib/test/test_importlib/extension/test_case_sensitivity.py +++ b/Lib/test/test_importlib/extension/test_case_sensitivity.py @@ -5,6 +5,7 @@ import unittest from .. import util +importlib = util.import_importlib('importlib') machinery = util.import_importlib('importlib.machinery') @@ -12,7 +13,7 @@ machinery = util.import_importlib('importlib.machinery') @unittest.skipIf(util.EXTENSIONS.filename is None, '_testcapi not available') @util.case_insensitive_tests -class ExtensionModuleCaseSensitivityTest: +class ExtensionModuleCaseSensitivityTest(util.CASEOKTestBase): def find_module(self): good_name = util.EXTENSIONS.name @@ -26,25 +27,22 @@ class ExtensionModuleCaseSensitivityTest: def test_case_sensitive(self): with support.EnvironmentVarGuard() as env: env.unset('PYTHONCASEOK') - if b'PYTHONCASEOK' in _bootstrap_external._os.environ: - self.skipTest('os.environ changes not reflected in ' - '_os.environ') + self.caseok_env_changed(should_exist=False) loader = self.find_module() self.assertIsNone(loader) def test_case_insensitivity(self): with support.EnvironmentVarGuard() as env: env.set('PYTHONCASEOK', '1') - if b'PYTHONCASEOK' not in _bootstrap_external._os.environ: - self.skipTest('os.environ changes not reflected in ' - '_os.environ') + self.caseok_env_changed(should_exist=True) loader = self.find_module() self.assertTrue(hasattr(loader, 'load_module')) (Frozen_ExtensionCaseSensitivity, Source_ExtensionCaseSensitivity - ) = util.test_both(ExtensionModuleCaseSensitivityTest, machinery=machinery) + ) = util.test_both(ExtensionModuleCaseSensitivityTest, importlib=importlib, + machinery=machinery) if __name__ == '__main__': diff --git a/Lib/test/test_importlib/source/test_case_sensitivity.py b/Lib/test/test_importlib/source/test_case_sensitivity.py index c4bf306..34b86cd 100644 --- a/Lib/test/test_importlib/source/test_case_sensitivity.py +++ b/Lib/test/test_importlib/source/test_case_sensitivity.py @@ -11,7 +11,7 @@ import unittest @util.case_insensitive_tests -class CaseSensitivityTest: +class CaseSensitivityTest(util.CASEOKTestBase): """PEP 235 dictates that on case-preserving, case-insensitive file systems that imports are case-sensitive unless the PYTHONCASEOK environment @@ -39,17 +39,10 @@ class CaseSensitivityTest: insensitive_finder = self.finder(insensitive_path) return self.find(sensitive_finder), self.find(insensitive_finder) - def env_changed(self, *, should_exist): - possibilities = b'PYTHONCASEOK', 'PYTHONCASEOK' - if any(x in self.importlib._bootstrap_external._os.environ - for x in possibilities) == should_exist: - self.skipTest('os.environ changes not reflected in ' - '_os.environ') - def test_sensitive(self): with test_support.EnvironmentVarGuard() as env: env.unset('PYTHONCASEOK') - self.env_changed(should_exist=False) + self.caseok_env_changed(should_exist=False) sensitive, insensitive = self.sensitivity_test() self.assertIsNotNone(sensitive) self.assertIn(self.name, sensitive.get_filename(self.name)) @@ -58,7 +51,7 @@ class CaseSensitivityTest: def test_insensitive(self): with test_support.EnvironmentVarGuard() as env: env.set('PYTHONCASEOK', '1') - self.env_changed(should_exist=True) + self.caseok_env_changed(should_exist=True) sensitive, insensitive = self.sensitivity_test() self.assertIsNotNone(sensitive) self.assertIn(self.name, sensitive.get_filename(self.name)) diff --git a/Lib/test/test_importlib/util.py b/Lib/test/test_importlib/util.py index ce20377..43896c5 100644 --- a/Lib/test/test_importlib/util.py +++ b/Lib/test/test_importlib/util.py @@ -378,3 +378,12 @@ def mock_path_hook(*entries, importer): raise ImportError return importer return hook + + +class CASEOKTestBase: + + def caseok_env_changed(self, *, should_exist): + possibilities = b'PYTHONCASEOK', 'PYTHONCASEOK' + if any(x in self.importlib._bootstrap_external._os.environ + for x in possibilities) != should_exist: + self.skipTest('os.environ changes not reflected in _os.environ') |