diff --git a/pytest/plugin/tmpdir.py b/pytest/plugin/tmpdir.py index cf91d2af5..0dde811aa 100644 --- a/pytest/plugin/tmpdir.py +++ b/pytest/plugin/tmpdir.py @@ -8,7 +8,7 @@ usage example:: .. _`py.path.local`: ../../path.html """ -import pytest +import pytest, py def pytest_configure(config): def ensuretemp(string, dir=1): @@ -30,5 +30,6 @@ def pytest_funcarg__tmpdir(request): path object. """ name = request._pyfuncitem.name + name = py.std.re.sub("[\W]", "_", name) x = request.config.mktemp(name, numbered=True) return x.realpath() diff --git a/testing/plugin/test_tmpdir.py b/testing/plugin/test_tmpdir.py index dfa050b84..29c255664 100644 --- a/testing/plugin/test_tmpdir.py +++ b/testing/plugin/test_tmpdir.py @@ -13,7 +13,12 @@ def test_funcarg(testdir): p = pytest_funcarg__tmpdir(FuncargRequest(item)) assert p.check() bn = p.basename.strip("0123456789") - assert bn.endswith("test_func[a]") + assert bn.endswith("test_func_a_") + item.name = "qwe/\\abc" + p = pytest_funcarg__tmpdir(FuncargRequest(item)) + assert p.check() + bn = p.basename.strip("0123456789") + assert bn == "qwe__abc" def test_ensuretemp(recwarn): #py.test.deprecated_call(py.test.ensuretemp, 'hello')