make safer filenames

--HG--
branch : trunk
This commit is contained in:
holger krekel 2010-10-21 16:10:37 +02:00
parent dc5e2f5ed3
commit 56afcfc9f3
2 changed files with 8 additions and 2 deletions

View File

@ -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()

View File

@ -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')