Issue #291 new

tmpdir names get too long on Windows (exceeding PATH_MAX)

Torsten Landschoff
created an issue

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:


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.

Comments (2)

  1. holger krekel repo owner

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

  2. Nenad Ognjanovic

    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)?

  3. Log in to comment