]> granicus.if.org Git - python/commitdiff
Remove custom test-skipping code in importlib tests for unittest code.
authorBrett Cannon <bcannon@gmail.com>
Mon, 20 Jul 2009 01:05:40 +0000 (01:05 +0000)
committerBrett Cannon <bcannon@gmail.com>
Mon, 20 Jul 2009 01:05:40 +0000 (01:05 +0000)
Lib/importlib/test/util.py

index 845e380bee89a69c6d0b254df44ca7403d7cb130..0c0c84c310bd3ed6d67c48bed5922ebcce3e44d3 100644 (file)
@@ -6,21 +6,22 @@ import unittest
 import sys
 
 
-def case_insensitive_tests(class_):
+CASE_INSENSITIVE_FS = True
+# Windows is the only OS that is *always* case-insensitive
+# (OS X *can* be case-sensitive).
+if sys.platform not in ('win32', 'cygwin'):
+    changed_name = __file__.upper()
+    if changed_name == __file__:
+        changed_name = __file__.lower()
+    if not os.path.exists(changed_name):
+        CASE_INSENSITIVE_FS = False
+
+
+def case_insensitive_tests(test):
     """Class decorator that nullifies tests requiring a case-insensitive
     file system."""
-    # Windows is the only OS that is *always* case-insensitive
-    # (OS X *can* be case-sensitive).
-    if sys.platform not in ('win32', 'cygwin'):
-        changed_name = __file__.upper()
-        if changed_name == __file__:
-            changed_name = __file__.lower()
-        if os.path.exists(changed_name):
-            return class_
-        else:
-            return unittest.TestCase
-    else:
-        return class_
+    return unittest.skipIf(not CASE_INSENSITIVE_FS,
+                            "requires a case-insensitive filesystem")(test)
 
 
 @contextmanager