2010-11-18 05:12:16 +08:00
|
|
|
import py, pytest
|
2010-10-10 19:48:49 +08:00
|
|
|
|
2010-11-13 18:10:45 +08:00
|
|
|
from _pytest.tmpdir import pytest_funcarg__tmpdir
|
|
|
|
from _pytest.python import FuncargRequest
|
2009-09-06 22:59:39 +08:00
|
|
|
|
|
|
|
def test_funcarg(testdir):
|
2010-10-17 06:24:59 +08:00
|
|
|
item = testdir.getitem("""
|
|
|
|
def pytest_generate_tests(metafunc):
|
|
|
|
metafunc.addcall(id='a')
|
|
|
|
metafunc.addcall(id='b')
|
|
|
|
def test_func(tmpdir): pass
|
|
|
|
""", 'test_func[a]')
|
2009-09-06 22:59:39 +08:00
|
|
|
p = pytest_funcarg__tmpdir(FuncargRequest(item))
|
|
|
|
assert p.check()
|
2010-04-27 22:10:25 +08:00
|
|
|
bn = p.basename.strip("0123456789")
|
2010-10-21 22:10:37 +08:00
|
|
|
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"
|
2010-10-10 19:48:49 +08:00
|
|
|
|
|
|
|
def test_ensuretemp(recwarn):
|
|
|
|
#py.test.deprecated_call(py.test.ensuretemp, 'hello')
|
|
|
|
d1 = py.test.ensuretemp('hello')
|
|
|
|
d2 = py.test.ensuretemp('hello')
|
|
|
|
assert d1 == d2
|
|
|
|
assert d1.check(dir=1)
|
|
|
|
|