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
|
|
|
|
import importlib
|
2009-02-01 00:00:05 -04:00
|
|
|
from .. import util
|
2009-01-17 20:24:28 -04:00
|
|
|
from . import test_path_hook
|
|
|
|
|
|
|
|
|
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):
|
|
|
|
good_name = test_path_hook.NAME
|
|
|
|
bad_name = good_name.upper()
|
|
|
|
assert good_name != bad_name
|
|
|
|
finder = importlib.ExtensionFileImporter(test_path_hook.PATH)
|
|
|
|
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')
|
|
|
|
loader = self.find_module()
|
|
|
|
self.assert_(loader is None)
|
|
|
|
|
|
|
|
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')
|
|
|
|
loader = self.find_module()
|
|
|
|
self.assert_(hasattr(loader, 'load_module'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_main():
|
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()
|