2009-01-17 20:24:28 -04:00
|
|
|
import sys
|
2009-02-01 00:00:05 -04:00
|
|
|
from test import support
|
2009-01-17 20:24:28 -04:00
|
|
|
import unittest
|
2009-03-12 19:47:53 -03:00
|
|
|
from importlib import _bootstrap
|
2009-02-01 00:00:05 -04:00
|
|
|
from .. import util
|
2009-02-06 22:06:43 -04:00
|
|
|
from . import util as ext_util
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
|
2009-02-01 00:00:05 -04:00
|
|
|
@util.case_insensitive_tests
|
2009-01-17 20:24:28 -04:00
|
|
|
class ExtensionModuleCaseSensitivityTest(unittest.TestCase):
|
|
|
|
|
|
|
|
def find_module(self):
|
2009-02-06 22:06:43 -04:00
|
|
|
good_name = ext_util.NAME
|
2009-01-17 20:24:28 -04:00
|
|
|
bad_name = good_name.upper()
|
|
|
|
assert good_name != bad_name
|
2010-07-03 18:48:25 -03:00
|
|
|
finder = _bootstrap._FileFinder(ext_util.PATH,
|
|
|
|
_bootstrap._ExtensionFinderDetails())
|
2009-01-17 20:24:28 -04:00
|
|
|
return finder.find_module(bad_name)
|
|
|
|
|
|
|
|
def test_case_sensitive(self):
|
2009-02-01 00:00:05 -04:00
|
|
|
with support.EnvironmentVarGuard() as env:
|
2009-01-17 20:24:28 -04:00
|
|
|
env.unset('PYTHONCASEOK')
|
2012-01-30 13:51:49 -04:00
|
|
|
if b'PYTHONCASEOK' in _bootstrap._os.environ:
|
|
|
|
self.skipTest('os.environ changes not reflected in '
|
|
|
|
'_os.environ')
|
2009-01-17 20:24:28 -04:00
|
|
|
loader = self.find_module()
|
2009-05-10 22:47:11 -03:00
|
|
|
self.assertIsNone(loader)
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
def test_case_insensitivity(self):
|
2009-02-01 00:00:05 -04:00
|
|
|
with support.EnvironmentVarGuard() as env:
|
2009-01-17 20:24:28 -04:00
|
|
|
env.set('PYTHONCASEOK', '1')
|
2012-01-30 13:51:49 -04:00
|
|
|
if b'PYTHONCASEOK' not in _bootstrap._os.environ:
|
|
|
|
self.skipTest('os.environ changes not reflected in '
|
|
|
|
'_os.environ')
|
2009-01-17 20:24:28 -04:00
|
|
|
loader = self.find_module()
|
2009-05-10 22:47:11 -03:00
|
|
|
self.assertTrue(hasattr(loader, 'load_module'))
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_main():
|
2009-03-08 17:50:32 -03:00
|
|
|
if ext_util.FILENAME is None:
|
|
|
|
return
|
2009-02-01 00:00:05 -04:00
|
|
|
support.run_unittest(ExtensionModuleCaseSensitivityTest)
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
test_main()
|