Skip to content

tmpdir names get too long on Windows (exceeding PATH_MAX) #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pytestbot opened this issue Apr 8, 2013 · 4 comments · Fixed by #6755
Closed

tmpdir names get too long on Windows (exceeding PATH_MAX) #291

pytestbot opened this issue Apr 8, 2013 · 4 comments · Fixed by #6755
Labels
type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Torsten Landschoff (BitBucket: bluehorn, GitHub: bluehorn)


Hi pytest Team,

we run into a lot of error in our release tests lately, which do not occur in nightly an on-commit tests. Looking into this, I discovered that path names get too long when we are using tmpdir:

c:\users\dynamore\appdata\local\temp\pytest-21\test_change_own_private_components_public_incoming_conflict_pull_C__jenkins_workspace_loco2_win7_32_client_release_testdata_testdb_dump_0\vaultdir\zipped\00\005292e500e4e76be18e798eccee423dec2e24c57db4b030348e67a7

On (german) Windows this results into

WindowsError: [Error 3] Das System kann den angegebenen Pfad nicht finden

which would point to a bug in our implementation.

It is unobvious to me that tmpdir includes the following info in the path:

  • the full function name
  • the parameters of the test call (full path to testdb.dump over here)

This can make the temporary path arbitrary long which causes problems on Windows. I think, py.test should shorten the path automatically (at least on Windows). We can work around this by passing relative filenames (less robust in case the code does a chdir, but that would break other tests anyway) and by shorting the names of our test functions. However, I would like to keep the test function names expressive.


@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


tmpdir should grow more intelligent about constructing its name, agreed. up for a patch? (_pytest/tmpdir.py and testing/test_tmpdir.py are affected i think).

@pytestbot
Copy link
Contributor Author

Original comment by Nenad Ognjanovic (BitBucket: bgr_, GitHub: bgr_):


Hi,
I've managed to overcome the limit on Windows by prefixing the path with \\?\ (as specified here). What do you think about this approach (and do you think it would be the right thing to integrate this workaround in py.path instead, since it looks like it fits there)?

@pytestbot pytestbot added the type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature label Jun 15, 2015
pytestbot pushed a commit that referenced this issue Jun 15, 2015
use new pluggy api (now at 0.3.0) for adding hookcall monitoring
@nicoddemus
Copy link
Member

This has been fixed for awhile now, tmpdir automatically truncates directory names to around 30 chars:

def test_tmpdir_test_change_own_private_components_public_incoming_conflict_pull_C__jenkins_workspace_loco2_win7_32_client_release_testdata_testdb_dump(tmpdir):
    print(tmpdir)
    assert 0 

Generates this path:

C:\Users\Bruno\AppData\Local\Temp\pytest-of-Bruno\pytest-173\test_tmpdir_test_change_own_pr0

So I'm closing this. 😄

cc @Bluehorn

@Bluehorn
Copy link

Agreed, looks fixed to me :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants