From 56afcfc9f340cde08ba5c7b618ccfbcdb4147f9c Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 21 Oct 2010 16:10:37 +0200 Subject: [PATCH] make safer filenames --HG-- branch : trunk --- pytest/plugin/tmpdir.py | 3 ++- testing/plugin/test_tmpdir.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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')