diff --git a/Lib/importlib/test/extension/test_case_sensitivity.py b/Lib/importlib/test/extension/test_case_sensitivity.py index c566b238937..575bf69f605 100644 --- a/Lib/importlib/test/extension/test_case_sensitivity.py +++ b/Lib/importlib/test/extension/test_case_sensitivity.py @@ -2,9 +2,11 @@ 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): @@ -30,8 +32,6 @@ def test_case_insensitivity(self): def test_main(): - if sys.platform not in ('win32', 'darwin', 'cygwin'): - return test_support.run_unittest(ExtensionModuleCaseSensitivityTest) diff --git a/Lib/importlib/test/source/test_case_sensitivity.py b/Lib/importlib/test/source/test_case_sensitivity.py index 1a5ff2f206c..6649f377e19 100644 --- a/Lib/importlib/test/source/test_case_sensitivity.py +++ b/Lib/importlib/test/source/test_case_sensitivity.py @@ -7,6 +7,7 @@ import unittest +@support.case_insensitive_tests class CaseSensitivityTest(unittest.TestCase): """PEP 235 dictates that on case-preserving, case-insensitive file systems @@ -48,8 +49,6 @@ def test_insensitive(self): def test_main(): - if sys.platform not in ('win32', 'darwin', 'cygwin'): - return test_support.run_unittest(CaseSensitivityTest) diff --git a/Lib/importlib/test/support.py b/Lib/importlib/test/support.py index 4e63cd1de86..3097811093d 100644 --- a/Lib/importlib/test/support.py +++ b/Lib/importlib/test/support.py @@ -36,6 +36,16 @@ def writes_bytecode(fxn): else: return fxn + +def case_insensitive_tests(class_): + """Class decorator that nullifies tests that require a case-insensitive + file system.""" + if sys.platform not in ('win32', 'darwin', 'cygwin'): + return object() + else: + return class_ + + @contextmanager def uncache(*names): """Uncache a module from sys.modules.