make tmpdir fixture always return a realpath()ed tmpdir and make a note
about it in the changed test. Currently, i don't see a reason why this is a bad idea (tm)
This commit is contained in:
parent
0594265adc
commit
6eec2f5893
|
@ -1,2 +1,2 @@
|
||||||
#
|
#
|
||||||
__version__ = '2.3.0.dev21'
|
__version__ = '2.3.0.dev22'
|
||||||
|
|
|
@ -40,7 +40,7 @@ class TempdirHandler:
|
||||||
basetemp.mkdir()
|
basetemp.mkdir()
|
||||||
else:
|
else:
|
||||||
basetemp = py.path.local.make_numbered_dir(prefix='pytest-')
|
basetemp = py.path.local.make_numbered_dir(prefix='pytest-')
|
||||||
self._basetemp = t = basetemp
|
self._basetemp = t = basetemp.realpath()
|
||||||
self.trace("new basetemp", t)
|
self.trace("new basetemp", t)
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -24,7 +24,7 @@ def main():
|
||||||
name='pytest',
|
name='pytest',
|
||||||
description='py.test: simple powerful testing with Python',
|
description='py.test: simple powerful testing with Python',
|
||||||
long_description = long_description,
|
long_description = long_description,
|
||||||
version='2.3.0.dev21',
|
version='2.3.0.dev22',
|
||||||
url='http://pytest.org',
|
url='http://pytest.org',
|
||||||
license='MIT license',
|
license='MIT license',
|
||||||
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
||||||
|
|
|
@ -72,14 +72,21 @@ def test_basetemp(testdir):
|
||||||
assert mytemp.join('hello').check()
|
assert mytemp.join('hello').check()
|
||||||
|
|
||||||
@pytest.mark.skipif("not hasattr(py.path.local, 'mksymlinkto')")
|
@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")
|
realtemp = testdir.tmpdir.mkdir("myrealtemp")
|
||||||
linktemp = testdir.tmpdir.join("symlinktemp")
|
linktemp = testdir.tmpdir.join("symlinktemp")
|
||||||
linktemp.mksymlinkto(realtemp)
|
linktemp.mksymlinkto(realtemp)
|
||||||
p = testdir.makepyfile("""
|
p = testdir.makepyfile("""
|
||||||
def test_1(tmpdir):
|
def test_1(tmpdir):
|
||||||
import os
|
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)
|
result = testdir.runpytest("-s", p, '--basetemp=%s/bt' % linktemp)
|
||||||
assert not result.ret
|
assert not result.ret
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue