示例#1
0
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"
示例#2
0
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"
示例#3
0
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
示例#4
0
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
示例#5
0
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"
示例#6
0
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"
示例#7
0
def session_tmpdir(request, tmpdir_factory):
    """pytest tmpdir which is session-scoped."""
    from _pytest.tmpdir import tmpdir
    return tmpdir(request, tmpdir_factory)
示例#8
0
def session_tmpdir(request):
    """pytest tmpdir which is session-scoped."""
    return tmpdir(request)
示例#9
0
 def startest(request):
     tmp = tmpdir(request)
     t = cls(tmp)
     return t
示例#10
0
def session_tmpdir(request):
    """pytest tmpdir which is session-scoped."""
    return tmpdir(request)
示例#11
0
 def startest(request):
     tmp = tmpdir(request)
     t = cls(tmp)
     return t
示例#12
0
def session_tmpdir(request, tmpdir_factory):
    """pytest tmpdir which is session-scoped."""
    from _pytest.tmpdir import tmpdir
    return tmpdir(request, tmpdir_factory)