diff --git a/CHANGELOG b/CHANGELOG index 06d43a305..bb58b94f1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,9 @@ Changes between 2.4.1 and 2.4.2 - avoid "IOError: Bad Filedescriptor" on pytest shutdown by not closing the internal dupped stdout (fix is slightly hand-wavy but work). +- avoid tmpdir fixture to create too long filenames especially + when parametrization is used (issue354) + Changes between 2.4.0 and 2.4.1 ----------------------------------- diff --git a/_pytest/tmpdir.py b/_pytest/tmpdir.py index 3907c92b7..8eb0cdec0 100644 --- a/_pytest/tmpdir.py +++ b/_pytest/tmpdir.py @@ -64,5 +64,8 @@ def tmpdir(request): """ name = request.node.name name = py.std.re.sub("[\W]", "_", name) + MAXVAL = 30 + if len(name) > MAXVAL: + name = name[:MAXVAL] x = request.config._tmpdirhandler.mktemp(name, numbered=True) return x diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py index 6ec790283..c058aa850 100644 --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -91,3 +91,12 @@ def test_tmpdir_always_is_realpath(testdir): result = testdir.runpytest("-s", p, '--basetemp=%s/bt' % linktemp) assert not result.ret +def test_tmpdir_too_long_on_parametrization(testdir): + testdir.makepyfile(""" + import pytest + @pytest.mark.parametrize("arg", ["1"*1000]) + def test_some(arg, tmpdir): + tmpdir.ensure("hello") + """) + reprec = testdir.inline_run() + reprec.assertoutcome(passed=1)