From 039037701a65da74caa93e2804f903babc2d21b3 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Sun, 17 Oct 2010 00:24:59 +0200 Subject: [PATCH] use pyfuncitem name for tmpdir in order to take generative test id into account --HG-- branch : trunk --- pytest/plugin/tmpdir.py | 2 +- testing/plugin/test_tmpdir.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pytest/plugin/tmpdir.py b/pytest/plugin/tmpdir.py index 79e1de257..cf91d2af5 100644 --- a/pytest/plugin/tmpdir.py +++ b/pytest/plugin/tmpdir.py @@ -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() diff --git a/testing/plugin/test_tmpdir.py b/testing/plugin/test_tmpdir.py index a15ec7e12..dfa050b84 100644 --- a/testing/plugin/test_tmpdir.py +++ b/testing/plugin/test_tmpdir.py @@ -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')