From 4302972c237a17a6b8e834939169bb187ba644bb Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 28 Jul 2015 20:35:13 -0300 Subject: [PATCH] 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 --- _pytest/tmpdir.py | 2 +- testing/test_tmpdir.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/_pytest/tmpdir.py b/_pytest/tmpdir.py index 9f9c4da6b..44e980e2e 100644 --- a/_pytest/tmpdir.py +++ b/_pytest/tmpdir.py @@ -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) diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py index 7c2095e6e..05b24fc59 100644 --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -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) \ No newline at end of file