Use pytest-of-$user as base directory for tmpdir_factory

Before tmpdir_factory, pytest used to create a link named "pytest-$user" to the current numbered directory. Use
 a different name so there's no conflict when running different pytest versions.

Fix #894
This commit is contained in:
Bruno Oliveira 2015-07-28 20:35:13 -03:00
parent 9cf9900721
commit 4302972c23
2 changed files with 15 additions and 1 deletions

View File

@ -56,7 +56,7 @@ class TempdirFactory:
# make_numbered_dir() call
import getpass
temproot = py.path.local.get_temproot()
rootdir = temproot.join('pytest-%s' % getpass.getuser())
rootdir = temproot.join('pytest-of-%s' % getpass.getuser())
rootdir.ensure(dir=1)
basetemp = py.path.local.make_numbered_dir(prefix='pytest-',
rootdir=rootdir)

View File

@ -95,6 +95,7 @@ def test_tmpdir_always_is_realpath(testdir):
result = testdir.runpytest("-s", p, '--basetemp=%s/bt' % linktemp)
assert not result.ret
def test_tmpdir_too_long_on_parametrization(testdir):
testdir.makepyfile("""
import pytest
@ -104,3 +105,16 @@ def test_tmpdir_too_long_on_parametrization(testdir):
""")
reprec = testdir.inline_run()
reprec.assertoutcome(passed=1)
def test_tmpdir_factory(testdir):
testdir.makepyfile("""
import pytest
@pytest.fixture(scope='session')
def session_dir(tmpdir_factory):
return tmpdir_factory.mktemp('data', numbered=False)
def test_some(session_dir):
session_dir.isdir()
""")
reprec = testdir.inline_run()
reprec.assertoutcome(passed=1)