]> granicus.if.org Git - python/commitdiff
Tests of case-sensitivity were being executed on OSs which did not have a
authorBrett Cannon <bcannon@gmail.com>
Sun, 18 Jan 2009 06:55:05 +0000 (06:55 +0000)
committerBrett Cannon <bcannon@gmail.com>
Sun, 18 Jan 2009 06:55:05 +0000 (06:55 +0000)
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.

Lib/importlib/test/extension/test_case_sensitivity.py
Lib/importlib/test/source/test_case_sensitivity.py
Lib/importlib/test/support.py

index c566b23893792ffd2b489fa67fb26c78b7fde845..575bf69f6058e3c0cf94caa50445b89ab4de9e49 100644 (file)
@@ -2,9 +2,11 @@ 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):
@@ -30,8 +32,6 @@ class ExtensionModuleCaseSensitivityTest(unittest.TestCase):
 
 
 def test_main():
-    if sys.platform not in ('win32', 'darwin', 'cygwin'):
-        return
     test_support.run_unittest(ExtensionModuleCaseSensitivityTest)
 
 
index 1a5ff2f206cdb48afa347aa310e3787662dc19c2..6649f377e1946ef4778546168ffda8d4d17d205b 100644 (file)
@@ -7,6 +7,7 @@ from test import support as test_support
 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 @@ class CaseSensitivityTest(unittest.TestCase):
 
 
 def test_main():
-    if sys.platform not in ('win32', 'darwin', 'cygwin'):
-        return
     test_support.run_unittest(CaseSensitivityTest)
 
 
index 4e63cd1de86751583efd51056c1a2fd3657d0ce0..3097811093db97e6cbfca638685e88773b66e5b5 100644 (file)
@@ -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.