slightly refine invocation of py.test: use the py lib that we got invoked with,

does away with the need to not-chdir some tests

--HG--
branch : trunk
This commit is contained in:
holger krekel 2010-01-02 11:57:42 +01:00
parent fd76cd8f41
commit a20e60aeae
2 changed files with 4 additions and 5 deletions

View File

@ -69,8 +69,7 @@ class TmpTestdir:
self.tmpdir = tmpdir.mkdir(name)
self.plugins = []
self._syspathremove = []
if not hasattr(request.function, "nochdir"):
self.chdir() # always chdir
self.chdir() # always chdir
self.request.addfinalizer(self.finalize)
def __repr__(self):
@ -316,7 +315,9 @@ class TmpTestdir:
else:
cmdlinename = scriptname.replace(".", "")
assert hasattr(py.cmdline, cmdlinename), cmdlinename
source = "import py ; py.cmdline.%s()" % cmdlinename
source = ("import sys ; sys.path.insert(0, %r); "
"import py ; py.cmdline.%s()" %
(str(py._dir.dirpath()), cmdlinename))
return (sys.executable, "-c", source,)
def runpython(self, script):

View File

@ -4,8 +4,6 @@ import subprocess
def pytest_funcarg__standalone(request):
return request.cached_setup(scope="module", setup=lambda: Standalone(request))
pytestmark = py.test.mark.nochdir
class Standalone:
def __init__(self, request):
self.testdir = request.getfuncargvalue("testdir")