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
|
2009-03-12 19:47:53 -03:00
|
|
|
finder = _bootstrap._ExtensionFileFinder(ext_util.PATH)
|
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')
|
|
|
|
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-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()
|