]> granicus.if.org Git - python/commitdiff
compileall tests: Use shorter name for long_path test (GH-16419)
authorPetr Viktorin <encukou@gmail.com>
Thu, 26 Sep 2019 13:16:32 +0000 (15:16 +0200)
committerGitHub <noreply@github.com>
Thu, 26 Sep 2019 13:16:32 +0000 (15:16 +0200)
Apparently, the path needs to be limited to 260 characters on
(some versions of) Windows.

Lib/test/test_compileall.py

index 205457f3b4801e7a710fe1e7071f8638bc1cae38..3bb03b3dd384640669d620f2a114ff79ca6fb65e 100644 (file)
@@ -53,7 +53,7 @@ class CompileallTestsBase:
         # It will be 100 directories deep, or shorter if the OS limits it.
         for i in range(10):
             longer_path = os.path.join(
-                long_path, *(f"long_directory_{i}_{j}" for j in range(10))
+                long_path, *(f"dir_{i}_{j}" for j in range(10))
             )
 
             # Check if we can open __pycache__/*.pyc.
@@ -87,8 +87,12 @@ class CompileallTestsBase:
             long_source = longer_source
             long_cache = longer_cache
 
+        # On Windows, MAX_PATH is 260 characters, our path with the 20
+        # directories is 160 characters long, leaving something for the
+        # root (self.directory) as well.
+        # Tests assume long_path contains at least 10 directories.
         if i < 2:
-            raise ValueError('Path limit is too short')
+            raise ValueError(f'"Long path" is too short: {long_path}')
 
         self.source_path_long = long_source
         self.bc_path_long = long_cache