mirror of
https://github.com/python/cpython.git
synced 2025-07-22 18:55:22 +00:00

case-insensitive file system, leading to test failures. This was due to using the TestCase objects directly instead of the guard in the test_main() function. Move over to a class decorator instead to control if the tests should be run.
39 lines
1 KiB
Python
39 lines
1 KiB
Python
import sys
|
|
from test import support as test_support
|
|
import unittest
|
|
import importlib
|
|
from .. import support
|
|
from . import test_path_hook
|
|
|
|
|
|
@support.case_insensitive_tests
|
|
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):
|
|
with test_support.EnvironmentVarGuard() as env:
|
|
env.unset('PYTHONCASEOK')
|
|
loader = self.find_module()
|
|
self.assert_(loader is None)
|
|
|
|
def test_case_insensitivity(self):
|
|
with test_support.EnvironmentVarGuard() as env:
|
|
env.set('PYTHONCASEOK', '1')
|
|
loader = self.find_module()
|
|
self.assert_(hasattr(loader, 'load_module'))
|
|
|
|
|
|
|
|
|
|
def test_main():
|
|
test_support.run_unittest(ExtensionModuleCaseSensitivityTest)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
test_main()
|