use pyfuncitem name for tmpdir in order to take generative test id into account

--HG--
branch : trunk
This commit is contained in:
Ronny Pfannschmidt 2010-10-17 00:24:59 +02:00
parent 80778eb3ae
commit 039037701a
2 changed files with 8 additions and 3 deletions

View File

@ -29,6 +29,6 @@ def pytest_funcarg__tmpdir(request):
directory. The returned object is a `py.path.local`_
path object.
"""
name = request.function.__name__
name = request._pyfuncitem.name
x = request.config.mktemp(name, numbered=True)
return x.realpath()

View File

@ -4,11 +4,16 @@ from pytest.plugin.tmpdir import pytest_funcarg__tmpdir
from pytest.plugin.python import FuncargRequest
def test_funcarg(testdir):
item = testdir.getitem("def test_func(tmpdir): pass")
item = testdir.getitem("""
def pytest_generate_tests(metafunc):
metafunc.addcall(id='a')
metafunc.addcall(id='b')
def test_func(tmpdir): pass
""", 'test_func[a]')
p = pytest_funcarg__tmpdir(FuncargRequest(item))
assert p.check()
bn = p.basename.strip("0123456789")
assert bn.endswith("test_func")
assert bn.endswith("test_func[a]")
def test_ensuretemp(recwarn):
#py.test.deprecated_call(py.test.ensuretemp, 'hello')