Tests for case-senstivity were not being skipped for darwin when installed on a
case-sensitive filesystems -- which is not the default case. Along the way also
fixed the skipping of tests when sys.dont_write_bytecode is true.
Closes issue #5442 again.
diff --git a/Lib/importlib/test/util.py b/Lib/importlib/test/util.py
index 9ff54a2..845e380 100644
--- a/Lib/importlib/test/util.py
+++ b/Lib/importlib/test/util.py
@@ -7,17 +7,18 @@
def case_insensitive_tests(class_):
- """Class decorator that nullifies tests that require a case-insensitive
+ """Class decorator that nullifies tests requiring a case-insensitive
file system."""
- if sys.platform not in ('win32', 'darwin', 'cygwin'):
- original_name = os.listdir('.')[0]
- if original_name.upper() != original_name:
- changed_name = original_name.upper()
- else:
- changed_name = original_name.lower()
+ # 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_
- return unittest.TestCase
+ else:
+ return unittest.TestCase
else:
return class_