]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue14255 Don't flatten case of tempdir
authorTim Golden <mail@timgolden.me.uk>
Fri, 25 Oct 2013 17:38:16 +0000 (18:38 +0100)
committerTim Golden <mail@timgolden.me.uk>
Fri, 25 Oct 2013 17:38:16 +0000 (18:38 +0100)
Lib/tempfile.py
Lib/test/test_tempfile.py
Lib/test/test_zipimport_support.py

index 7da71c8c3bc4e55a708f697b9523003ef7ce0b4b..5d3462102f19443faa6f1bd39b111c5bf695ff32 100644 (file)
@@ -146,7 +146,7 @@ def _get_default_tempdir():
 
     for dir in dirlist:
         if dir != _os.curdir:
-            dir = _os.path.normcase(_os.path.abspath(dir))
+            dir = _os.path.abspath(dir)
         # Try only a few names per directory.
         for seq in range(100):
             name = next(namer)
index 1ee36e223b9b91266aec06a913c9a8fa12a6679a..ac4d8609dfe21ab93ce9649cedb36daac263e5c2 100644 (file)
@@ -478,6 +478,20 @@ class TestGetTempDir(BaseTestCase):
 
         self.assertTrue(a is b)
 
+    def test_case_sensitive(self):
+        # gettempdir should not flatten its case
+        # even on a case-insensitive file system
+        case_sensitive_tempdir = tempfile.mkdtemp("-Temp")
+        _tempdir, tempfile.tempdir = tempfile.tempdir, None
+        try:
+            with support.EnvironmentVarGuard() as env:
+                # Fake the first env var which is checked as a candidate
+                env["TMPDIR"] = case_sensitive_tempdir
+                self.assertEqual(tempfile.gettempdir(), case_sensitive_tempdir)
+        finally:
+            tempfile.tempdir = _tempdir
+            support.rmdir(case_sensitive_tempdir)
+
 
 class TestMkstemp(BaseTestCase):
     """Test mkstemp()."""
index f7f3398015a889b35293db31c1e1c58b0350c0e9..84ba5e047a3673a7adbadfd18ddfdfb8e3b92a19 100644 (file)
@@ -227,13 +227,15 @@ class ZipSupportTests(unittest.TestCase):
             p = spawn_python(script_name)
             p.stdin.write(b'l\n')
             data = kill_python(p)
-            self.assertIn(script_name.encode('utf-8'), data)
+            # bdb/pdb applies normcase to its filename before displaying
+            self.assertIn(os.path.normcase(script_name.encode('utf-8')), data)
             zip_name, run_name = make_zip_script(d, "test_zip",
                                                 script_name, '__main__.py')
             p = spawn_python(zip_name)
             p.stdin.write(b'l\n')
             data = kill_python(p)
-            self.assertIn(run_name.encode('utf-8'), data)
+            # bdb/pdb applies normcase to its filename before displaying
+            self.assertIn(os.path.normcase(run_name.encode('utf-8')), data)
 
 
 def test_main():