summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_importlib
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2016-07-15 18:54:38 (GMT)
committerBrett Cannon <brett@python.org>2016-07-15 18:54:38 (GMT)
commita47a7a5bf88c72d85f322f528381ebfa924072e9 (patch)
treea2581d2ef9a3909a320df6de9a9134bb91c3f3d1 /Lib/test/test_importlib
parentf76457e12203d301c94e33957ff7121a24856b83 (diff)
downloadcpython-a47a7a5bf88c72d85f322f528381ebfa924072e9.zip
cpython-a47a7a5bf88c72d85f322f528381ebfa924072e9.tar.gz
cpython-a47a7a5bf88c72d85f322f528381ebfa924072e9.tar.bz2
Issue #27083: Respect the PYTHONCASEOK environment variable under
Windows. Originally only b'PYTHONCASEOK' was being checked for in os.environ, but that won't work under Windows where all environment variables are strings (on OS X they are bytes). Thanks to Eryk Sun for the bug report.
Diffstat (limited to 'Lib/test/test_importlib')
-rw-r--r--Lib/test/test_importlib/source/test_case_sensitivity.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/Lib/test/test_importlib/source/test_case_sensitivity.py b/Lib/test/test_importlib/source/test_case_sensitivity.py
index c274b38..c4bf306 100644
--- a/Lib/test/test_importlib/source/test_case_sensitivity.py
+++ b/Lib/test/test_importlib/source/test_case_sensitivity.py
@@ -39,12 +39,17 @@ 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')
- if b'PYTHONCASEOK' in self.importlib._bootstrap_external._os.environ:
- self.skipTest('os.environ changes not reflected in '
- '_os.environ')
+ self.env_changed(should_exist=False)
sensitive, insensitive = self.sensitivity_test()
self.assertIsNotNone(sensitive)
self.assertIn(self.name, sensitive.get_filename(self.name))
@@ -53,9 +58,7 @@ class CaseSensitivityTest:
def test_insensitive(self):
with test_support.EnvironmentVarGuard() as env:
env.set('PYTHONCASEOK', '1')
- if b'PYTHONCASEOK' not in self.importlib._bootstrap_external._os.environ:
- self.skipTest('os.environ changes not reflected in '
- '_os.environ')
+ self.env_changed(should_exist=True)
sensitive, insensitive = self.sensitivity_test()
self.assertIsNotNone(sensitive)
self.assertIn(self.name, sensitive.get_filename(self.name))