diff --git a/_pytest/__init__.py b/_pytest/__init__.py index 7da3bfaab..1bf0aed26 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.3.0.dev21' +__version__ = '2.3.0.dev22' diff --git a/_pytest/tmpdir.py b/_pytest/tmpdir.py index c67f4389e..367d54e4e 100644 --- a/_pytest/tmpdir.py +++ b/_pytest/tmpdir.py @@ -40,7 +40,7 @@ class TempdirHandler: basetemp.mkdir() else: basetemp = py.path.local.make_numbered_dir(prefix='pytest-') - self._basetemp = t = basetemp + self._basetemp = t = basetemp.realpath() self.trace("new basetemp", t) return t diff --git a/setup.py b/setup.py index 691f02210..cf411aea5 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.3.0.dev21', + version='2.3.0.dev22', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py index f7d519164..7ed53e820 100644 --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -72,14 +72,21 @@ def test_basetemp(testdir): assert mytemp.join('hello').check() @pytest.mark.skipif("not hasattr(py.path.local, 'mksymlinkto')") -def test_tmpdir_keeps_symlinks(testdir): +def test_tmpdir_always_is_realpath(testdir): + # the reason why tmpdir should be a realpath is that + # when you cd to it and do "os.getcwd()" you will anyway + # get the realpath. Using the symlinked path can thus + # easily result in path-inequality + # XXX if that proves to be a problem, consider using + # os.environ["PWD"] realtemp = testdir.tmpdir.mkdir("myrealtemp") linktemp = testdir.tmpdir.join("symlinktemp") linktemp.mksymlinkto(realtemp) p = testdir.makepyfile(""" def test_1(tmpdir): import os - assert os.path.realpath(str(tmpdir)) != str(tmpdir) + assert os.path.realpath(str(tmpdir)) == str(tmpdir) """) result = testdir.runpytest("-s", p, '--basetemp=%s/bt' % linktemp) assert not result.ret +