2015-05-02 22:15:18 -03:00
|
|
|
from importlib import _bootstrap_external
|
2009-02-01 00:00:05 -04:00
|
|
|
from test import support
|
2009-01-17 20:24:28 -04:00
|
|
|
import unittest
|
2013-06-15 19:39:21 -03:00
|
|
|
|
2009-02-01 00:00:05 -04:00
|
|
|
from .. import util
|
2013-09-03 21:43:49 -03:00
|
|
|
|
2016-07-16 14:44:13 -03:00
|
|
|
importlib = util.import_importlib('importlib')
|
2014-05-16 14:40:40 -03:00
|
|
|
machinery = util.import_importlib('importlib.machinery')
|
2013-10-25 16:39:02 -03:00
|
|
|
|
2009-01-17 20:24:28 -04:00
|
|
|
|
2014-05-09 15:32:57 -03:00
|
|
|
@unittest.skipIf(util.EXTENSIONS.filename is None, '_testcapi not available')
|
2009-02-01 00:00:05 -04:00
|
|
|
@util.case_insensitive_tests
|
2016-07-16 14:44:13 -03:00
|
|
|
class ExtensionModuleCaseSensitivityTest(util.CASEOKTestBase):
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
def find_module(self):
|
2014-05-09 15:32:57 -03:00
|
|
|
good_name = util.EXTENSIONS.name
|
2009-01-17 20:24:28 -04:00
|
|
|
bad_name = good_name.upper()
|
|
|
|
assert good_name != bad_name
|
2014-05-09 15:32:57 -03:00
|
|
|
finder = self.machinery.FileFinder(util.EXTENSIONS.path,
|
2013-10-25 16:39:02 -03:00
|
|
|
(self.machinery.ExtensionFileLoader,
|
|
|
|
self.machinery.EXTENSION_SUFFIXES))
|
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')
|
2016-07-16 14:44:13 -03:00
|
|
|
self.caseok_env_changed(should_exist=False)
|
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):
|
2013-09-03 21:43:49 -03:00
|
|
|
with support.EnvironmentVarGuard() as env:
|
|
|
|
env.set('PYTHONCASEOK', '1')
|
2016-07-16 14:44:13 -03:00
|
|
|
self.caseok_env_changed(should_exist=True)
|
2013-09-03 21:43:49 -03:00
|
|
|
loader = self.find_module()
|
|
|
|
self.assertTrue(hasattr(loader, 'load_module'))
|
2009-01-17 20:24:28 -04:00
|
|
|
|
2014-05-16 14:40:40 -03:00
|
|
|
|
|
|
|
(Frozen_ExtensionCaseSensitivity,
|
|
|
|
Source_ExtensionCaseSensitivity
|
2016-07-16 14:44:13 -03:00
|
|
|
) = util.test_both(ExtensionModuleCaseSensitivityTest, importlib=importlib,
|
|
|
|
machinery=machinery)
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2013-10-25 16:39:02 -03:00
|
|
|
unittest.main()
|