forked from Rust-related/RustPython
* Mark 3.12 * Update importlib from Python 3.12.0 * Update test_importlib from Python3.12 * Mark failings tests from importlib * Update test.support from Python3.12 * Fix unsupported parser feature * mark failing test * Update functools from Python 3.12 * manual type annotation * slice behavior changed in 3.12 * empty unittest.main returns non-zero * test_decimal from CPython 3.12 * Mark failing tests * Update test_unicode from CPython 3.12 * Update test_functools from Python 3.12 * Update enum from Python 3.12 * enum * Doc format changed * Update test_module from CPython --------- Co-authored-by: CPython developers <>
49 lines
1.7 KiB
Python
Vendored
49 lines
1.7 KiB
Python
Vendored
from importlib import _bootstrap_external
|
|
from test.support import os_helper
|
|
import unittest
|
|
import sys
|
|
from test.test_importlib import util
|
|
|
|
importlib = util.import_importlib('importlib')
|
|
machinery = util.import_importlib('importlib.machinery')
|
|
|
|
|
|
@unittest.skipIf(util.EXTENSIONS.filename is None, f'{util.EXTENSIONS.name} not available')
|
|
@util.case_insensitive_tests
|
|
class ExtensionModuleCaseSensitivityTest(util.CASEOKTestBase):
|
|
|
|
def find_spec(self):
|
|
good_name = util.EXTENSIONS.name
|
|
bad_name = good_name.upper()
|
|
assert good_name != bad_name
|
|
finder = self.machinery.FileFinder(util.EXTENSIONS.path,
|
|
(self.machinery.ExtensionFileLoader,
|
|
self.machinery.EXTENSION_SUFFIXES))
|
|
return finder.find_spec(bad_name)
|
|
|
|
@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
|
|
def test_case_sensitive(self):
|
|
with os_helper.EnvironmentVarGuard() as env:
|
|
env.unset('PYTHONCASEOK')
|
|
self.caseok_env_changed(should_exist=False)
|
|
spec = self.find_spec()
|
|
self.assertIsNone(spec)
|
|
|
|
@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
|
|
def test_case_insensitivity(self):
|
|
with os_helper.EnvironmentVarGuard() as env:
|
|
env.set('PYTHONCASEOK', '1')
|
|
self.caseok_env_changed(should_exist=True)
|
|
spec = self.find_spec()
|
|
self.assertTrue(spec)
|
|
|
|
|
|
(Frozen_ExtensionCaseSensitivity,
|
|
Source_ExtensionCaseSensitivity
|
|
) = util.test_both(ExtensionModuleCaseSensitivityTest, importlib=importlib,
|
|
machinery=machinery)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|