[Python-checkins] r68712 - in python/branches/py3k/Lib/importlib/test: extension/test_case_sensitivity.py source/test_case_sensitivity.py support.py

brett.cannon python-checkins at python.org
Sun Jan 18 07:55:05 CET 2009


Author: brett.cannon
Date: Sun Jan 18 07:55:05 2009
New Revision: 68712

Log:
Tests of case-sensitivity were being executed on OSs which did not have a
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.


Modified:
   python/branches/py3k/Lib/importlib/test/extension/test_case_sensitivity.py
   python/branches/py3k/Lib/importlib/test/source/test_case_sensitivity.py
   python/branches/py3k/Lib/importlib/test/support.py

Modified: python/branches/py3k/Lib/importlib/test/extension/test_case_sensitivity.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/extension/test_case_sensitivity.py	(original)
+++ python/branches/py3k/Lib/importlib/test/extension/test_case_sensitivity.py	Sun Jan 18 07:55:05 2009
@@ -2,9 +2,11 @@
 from test import support as test_support
 import unittest
 import importlib
+from .. import support
 from . import test_path_hook
 
 
+ at support.case_insensitive_tests
 class ExtensionModuleCaseSensitivityTest(unittest.TestCase):
 
     def find_module(self):
@@ -30,8 +32,6 @@
 
 
 def test_main():
-    if sys.platform not in ('win32', 'darwin', 'cygwin'):
-        return
     test_support.run_unittest(ExtensionModuleCaseSensitivityTest)
 
 

Modified: python/branches/py3k/Lib/importlib/test/source/test_case_sensitivity.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/source/test_case_sensitivity.py	(original)
+++ python/branches/py3k/Lib/importlib/test/source/test_case_sensitivity.py	Sun Jan 18 07:55:05 2009
@@ -7,6 +7,7 @@
 import unittest
 
 
+ at 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_main():
-    if sys.platform not in ('win32', 'darwin', 'cygwin'):
-        return
     test_support.run_unittest(CaseSensitivityTest)
 
 

Modified: python/branches/py3k/Lib/importlib/test/support.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/support.py	(original)
+++ python/branches/py3k/Lib/importlib/test/support.py	Sun Jan 18 07:55:05 2009
@@ -36,6 +36,16 @@
     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.


More information about the Python-checkins mailing list