def test_funcarg(testdir): testdir.makepyfile( """ def pytest_generate_tests(metafunc): metafunc.addcall(id='a') metafunc.addcall(id='b') def test_func(tmpdir): pass """ ) reprec = testdir.inline_run() calls = reprec.getcalls("pytest_runtest_setup") item = calls[0].item # pytest_unconfigure has deleted the TempdirHandler already config = item.config config._tmpdirhandler = TempdirHandler(config) item._initrequest() p = tmpdir(item._request) assert p.check() bn = p.basename.strip("0123456789") assert bn.endswith("test_func_a_") item.name = "qwe/\\abc" p = tmpdir(item._request) assert p.check() bn = p.basename.strip("0123456789") assert bn == "qwe__abc"
def test_funcarg(testdir): testdir.makepyfile( """ def pytest_generate_tests(metafunc): metafunc.addcall(id='a') metafunc.addcall(id='b') def test_func(tmpdir): pass """ ) from _pytest.tmpdir import TempdirFactory reprec = testdir.inline_run() calls = reprec.getcalls("pytest_runtest_setup") item = calls[0].item config = item.config tmpdirhandler = TempdirFactory(config) item._initrequest() p = tmpdir(item._request, tmpdirhandler) assert p.check() bn = p.basename.strip("0123456789") assert bn.endswith("test_func_a_") item.name = "qwe/\\abc" p = tmpdir(item._request, tmpdirhandler) assert p.check() bn = p.basename.strip("0123456789") assert bn == "qwe__abc"
def basedir(request, tmpdir_factory): from _pytest.tmpdir import tmpdir tmpdir = tmpdir(request, tmpdir_factory) tmpdir.ensure("adir/conftest.py").write("a=1 ; Directory = 3") tmpdir.ensure("adir/b/conftest.py").write("b=2 ; a = 1.5") if request.param == "inpackage": tmpdir.ensure("adir/__init__.py") tmpdir.ensure("adir/b/__init__.py") return tmpdir
def basedir(request): from _pytest.tmpdir import tmpdir tmpdir = tmpdir(request) tmpdir.ensure("adir/conftest.py").write("a=1 ; Directory = 3") tmpdir.ensure("adir/b/conftest.py").write("b=2 ; a = 1.5") if request.param == "inpackage": tmpdir.ensure("adir/__init__.py") tmpdir.ensure("adir/b/__init__.py") return tmpdir
def test_funcarg(testdir): testdir.makepyfile(""" def pytest_generate_tests(metafunc): metafunc.addcall(id='a') metafunc.addcall(id='b') def test_func(tmpdir): pass """) reprec = testdir.inline_run() calls = reprec.getcalls("pytest_runtest_setup") item = calls[0].item # pytest_unconfigure has deleted the TempdirHandler already config = item.config config._tmpdirhandler = TempdirHandler(config) p = tmpdir(item._request) assert p.check() bn = p.basename.strip("0123456789") assert bn.endswith("test_func_a_") item.name = "qwe/\\abc" p = tmpdir(item._request) assert p.check() bn = p.basename.strip("0123456789") assert bn == "qwe__abc"
def test_funcarg(testdir): testdir.makepyfile(""" def pytest_generate_tests(metafunc): metafunc.addcall(id='a') metafunc.addcall(id='b') def test_func(tmpdir): pass """) from _pytest.tmpdir import TempdirFactory reprec = testdir.inline_run() calls = reprec.getcalls("pytest_runtest_setup") item = calls[0].item config = item.config tmpdirhandler = TempdirFactory(config) item._initrequest() p = tmpdir(item._request, tmpdirhandler) assert p.check() bn = p.basename.strip("0123456789") assert bn.endswith("test_func_a_") item.name = "qwe/\\abc" p = tmpdir(item._request, tmpdirhandler) assert p.check() bn = p.basename.strip("0123456789") assert bn == "qwe__abc"
def session_tmpdir(request, tmpdir_factory): """pytest tmpdir which is session-scoped.""" from _pytest.tmpdir import tmpdir return tmpdir(request, tmpdir_factory)
def session_tmpdir(request): """pytest tmpdir which is session-scoped.""" return tmpdir(request)
def startest(request): tmp = tmpdir(request) t = cls(tmp) return t