fix standalone script generation on windows, make tests not do a chdir() so that distributed testing discovers the transferred lib
--HG-- branch : trunk
This commit is contained in:
parent
47df1e16b6
commit
e0dd171e45
|
@ -40,7 +40,7 @@ def main(pybasedir, outfile, infile):
|
||||||
|
|
||||||
name2src = {}
|
name2src = {}
|
||||||
for f in files:
|
for f in files:
|
||||||
k = f.replace("/", ".")[:-3]
|
k = f.replace(os.sep, ".")[:-3]
|
||||||
name2src[k] = open(f, "rb").read()
|
name2src[k] = open(f, "rb").read()
|
||||||
|
|
||||||
data = pickle.dumps(name2src, 2)
|
data = pickle.dumps(name2src, 2)
|
||||||
|
|
|
@ -69,8 +69,8 @@ class TmpTestdir:
|
||||||
self.tmpdir = tmpdir.mkdir(name)
|
self.tmpdir = tmpdir.mkdir(name)
|
||||||
self.plugins = []
|
self.plugins = []
|
||||||
self._syspathremove = []
|
self._syspathremove = []
|
||||||
self.chdir() # always chdir
|
if not hasattr(request.function, "nochdir"):
|
||||||
assert hasattr(self, '_olddir')
|
self.chdir() # always chdir
|
||||||
self.request.addfinalizer(self.finalize)
|
self.request.addfinalizer(self.finalize)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@ -280,12 +280,7 @@ class TmpTestdir:
|
||||||
return py.std.subprocess.Popen(cmdargs, stdout=stdout, stderr=stderr, **kw)
|
return py.std.subprocess.Popen(cmdargs, stdout=stdout, stderr=stderr, **kw)
|
||||||
|
|
||||||
def run(self, *cmdargs):
|
def run(self, *cmdargs):
|
||||||
old = self.tmpdir.chdir()
|
return self._run(*cmdargs)
|
||||||
#print "chdir", self.tmpdir
|
|
||||||
try:
|
|
||||||
return self._run(*cmdargs)
|
|
||||||
finally:
|
|
||||||
old.chdir()
|
|
||||||
|
|
||||||
def _run(self, *cmdargs):
|
def _run(self, *cmdargs):
|
||||||
cmdargs = [str(x) for x in cmdargs]
|
cmdargs = [str(x) for x in cmdargs]
|
||||||
|
|
|
@ -4,11 +4,15 @@ import subprocess
|
||||||
def pytest_funcarg__standalone(request):
|
def pytest_funcarg__standalone(request):
|
||||||
return request.cached_setup(scope="module", setup=lambda: Standalone(request))
|
return request.cached_setup(scope="module", setup=lambda: Standalone(request))
|
||||||
|
|
||||||
|
pytestmark = py.test.mark.nochdir
|
||||||
|
|
||||||
class Standalone:
|
class Standalone:
|
||||||
def __init__(self, request):
|
def __init__(self, request):
|
||||||
self.testdir = request.getfuncargvalue("testdir")
|
self.testdir = request.getfuncargvalue("testdir")
|
||||||
self.script = self.testdir.tmpdir.join("mypytest")
|
self.script = self.testdir.tmpdir.join("mypytest")
|
||||||
self.testdir.runpytest("--genscript=%s" % self.script)
|
result = self.testdir.runpytest("--genscript=%s" % self.script)
|
||||||
|
assert result.ret == 0
|
||||||
|
assert self.script.check()
|
||||||
|
|
||||||
def run(self, anypython, testdir, *args):
|
def run(self, anypython, testdir, *args):
|
||||||
testdir.chdir()
|
testdir.chdir()
|
||||||
|
|
Loading…
Reference in New Issue