summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_importlib/extension/test_case_sensitivity.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-07-20 18:48:53 (GMT)
committerBrett Cannon <brett@python.org>2012-07-20 18:48:53 (GMT)
commit45a5e3afe52ed89f298242143c5f7e2bb992ac63 (patch)
tree2255a23f991f1452335d865939f6c30d7b2d7d48 /Lib/test/test_importlib/extension/test_case_sensitivity.py
parent4afc1c08d04a9c083b654178ea4f947563510836 (diff)
downloadcpython-45a5e3afe52ed89f298242143c5f7e2bb992ac63.zip
cpython-45a5e3afe52ed89f298242143c5f7e2bb992ac63.tar.gz
cpython-45a5e3afe52ed89f298242143c5f7e2bb992ac63.tar.bz2
Issue #15168: Move importlb.test to test.test_importlib.
This should make the Linux distros happy as it is now easier to leave importlib's tests out of their base Python distribution.
Diffstat (limited to 'Lib/test/test_importlib/extension/test_case_sensitivity.py')
-rw-r--r--Lib/test/test_importlib/extension/test_case_sensitivity.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/Lib/test/test_importlib/extension/test_case_sensitivity.py b/Lib/test/test_importlib/extension/test_case_sensitivity.py
new file mode 100644
index 0000000..bdc21e7
--- /dev/null
+++ b/Lib/test/test_importlib/extension/test_case_sensitivity.py
@@ -0,0 +1,51 @@
+import imp
+import sys
+from test import support
+import unittest
+from importlib import _bootstrap
+from .. import util
+from . import util as ext_util
+
+
+@util.case_insensitive_tests
+class ExtensionModuleCaseSensitivityTest(unittest.TestCase):
+
+ def find_module(self):
+ good_name = ext_util.NAME
+ bad_name = good_name.upper()
+ assert good_name != bad_name
+ finder = _bootstrap.FileFinder(ext_util.PATH,
+ (_bootstrap.ExtensionFileLoader,
+ imp.extension_suffixes(),
+ False))
+ return finder.find_module(bad_name)
+
+ def test_case_sensitive(self):
+ with support.EnvironmentVarGuard() as env:
+ env.unset('PYTHONCASEOK')
+ if b'PYTHONCASEOK' in _bootstrap._os.environ:
+ self.skipTest('os.environ changes not reflected in '
+ '_os.environ')
+ 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._os.environ:
+ self.skipTest('os.environ changes not reflected in '
+ '_os.environ')
+ loader = self.find_module()
+ self.assertTrue(hasattr(loader, 'load_module'))
+
+
+
+
+def test_main():
+ if ext_util.FILENAME is None:
+ return
+ support.run_unittest(ExtensionModuleCaseSensitivityTest)
+
+
+if __name__ == '__main__':
+ test_main()