refine rsyncing and internal dir/transferal handling: don't transfer roots in a popen- no-chdir situation and only use one py._pydir everywhere
--HG-- branch : trunk
This commit is contained in:
parent
352e305431
commit
ba1451330e
|
@ -50,6 +50,8 @@ Changes between 1.X and 1.1.1
|
||||||
- change: pytest doctest plugin is now enabled by default and has a
|
- change: pytest doctest plugin is now enabled by default and has a
|
||||||
new option --doctest-glob to set a pattern for file matches.
|
new option --doctest-glob to set a pattern for file matches.
|
||||||
|
|
||||||
|
- change: remove internal py._* helper vars, only keep py._pydir
|
||||||
|
|
||||||
- robustify capturing to survive if custom pytest_runtest_setup
|
- robustify capturing to survive if custom pytest_runtest_setup
|
||||||
code failed and prevented the capturing setup code from running.
|
code failed and prevented the capturing setup code from running.
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ class RestWriter:
|
||||||
|
|
||||||
class PluginOverview(RestWriter):
|
class PluginOverview(RestWriter):
|
||||||
def makerest(self, config):
|
def makerest(self, config):
|
||||||
plugindir = py._dir.join('plugin')
|
plugindir = py._pydir.join('plugin')
|
||||||
for cat, specs in plugins:
|
for cat, specs in plugins:
|
||||||
pluginlist = specs.split()
|
pluginlist = specs.split()
|
||||||
self.h1(cat)
|
self.h1(cat)
|
||||||
|
|
|
@ -19,9 +19,7 @@ py.apipkg.initpkg(__name__, dict(
|
||||||
# access to all posix errno's as classes
|
# access to all posix errno's as classes
|
||||||
error = '.impl.error:error',
|
error = '.impl.error:error',
|
||||||
|
|
||||||
_impldir = '.impl._metainfo:impldir',
|
_pydir = '.impl._metainfo:pydir',
|
||||||
_dir = '.impl._metainfo:pydir',
|
|
||||||
_pydirs = '.impl._metainfo:pydirs',
|
|
||||||
version = 'py:__version__', # backward compatibility
|
version = 'py:__version__', # backward compatibility
|
||||||
|
|
||||||
cmdline = {
|
cmdline = {
|
||||||
|
|
|
@ -1,9 +1,2 @@
|
||||||
|
|
||||||
import py
|
import py
|
||||||
|
|
||||||
pydir = py.path.local(py.__file__).dirpath()
|
pydir = py.path.local(py.__file__).dirpath()
|
||||||
impldir = pydir.join("impl")
|
|
||||||
|
|
||||||
# list of all directories beloging to py
|
|
||||||
assert impldir.relto(pydir)
|
|
||||||
pydirs = [pydir]
|
|
||||||
|
|
|
@ -257,7 +257,7 @@ class Collector(Node):
|
||||||
path = self.fspath
|
path = self.fspath
|
||||||
ntraceback = traceback.cut(path=self.fspath)
|
ntraceback = traceback.cut(path=self.fspath)
|
||||||
if ntraceback == traceback:
|
if ntraceback == traceback:
|
||||||
ntraceback = ntraceback.cut(excludepath=py._dir)
|
ntraceback = ntraceback.cut(excludepath=py._pydir)
|
||||||
traceback = ntraceback.filter()
|
traceback = ntraceback.filter()
|
||||||
return traceback
|
return traceback
|
||||||
|
|
||||||
|
|
|
@ -269,21 +269,17 @@ class Config(object):
|
||||||
|
|
||||||
def getrsyncdirs(self):
|
def getrsyncdirs(self):
|
||||||
config = self
|
config = self
|
||||||
roots = config.option.rsyncdir
|
candidates = [py._pydir] + config.option.rsyncdir
|
||||||
conftestroots = config.getconftest_pathlist("rsyncdirs")
|
conftestroots = config.getconftest_pathlist("rsyncdirs")
|
||||||
if conftestroots:
|
if conftestroots:
|
||||||
roots.extend(conftestroots)
|
candidates.extend(conftestroots)
|
||||||
pydirs = [x.realpath() for x in py._pydirs]
|
roots = []
|
||||||
roots = [py.path.local(root) for root in roots]
|
for root in candidates:
|
||||||
for root in roots:
|
root = py.path.local(root).realpath()
|
||||||
if not root.check():
|
if not root.check():
|
||||||
raise config.Error("rsyncdir doesn't exist: %r" %(root,))
|
raise config.Error("rsyncdir doesn't exist: %r" %(root,))
|
||||||
if pydirs is not None and root.basename in ("py", "_py"):
|
if root not in roots:
|
||||||
try:
|
roots.append(root)
|
||||||
pydirs.remove(root) # otherwise it's a conflict
|
|
||||||
except ValueError: # we run as standalone py.test
|
|
||||||
pass
|
|
||||||
roots.extend(pydirs)
|
|
||||||
return roots
|
return roots
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import py
|
import py
|
||||||
import sys, os
|
import sys, os.path
|
||||||
import execnet
|
import execnet
|
||||||
from execnet.gateway_base import RemoteError
|
from execnet.gateway_base import RemoteError
|
||||||
|
|
||||||
|
@ -35,7 +35,12 @@ class GatewayManager:
|
||||||
gateways = []
|
gateways = []
|
||||||
for gateway in self.group:
|
for gateway in self.group:
|
||||||
spec = gateway.spec
|
spec = gateway.spec
|
||||||
if spec.popen and not spec.chdir and not spec.python:
|
if spec.popen and not spec.chdir:
|
||||||
|
# XXX this assumes that sources are python-packages
|
||||||
|
# and that adding the basedir does not hurt
|
||||||
|
gateway.remote_exec("""
|
||||||
|
import sys ; sys.path.insert(0, %r)
|
||||||
|
""" % os.path.dirname(str(source))).waitclose()
|
||||||
continue
|
continue
|
||||||
if spec not in seen:
|
if spec not in seen:
|
||||||
def finished():
|
def finished():
|
||||||
|
|
|
@ -246,7 +246,7 @@ class FunctionMixin(PyobjMixin):
|
||||||
if ntraceback == traceback:
|
if ntraceback == traceback:
|
||||||
ntraceback = ntraceback.cut(path=path)
|
ntraceback = ntraceback.cut(path=path)
|
||||||
if ntraceback == traceback:
|
if ntraceback == traceback:
|
||||||
ntraceback = ntraceback.cut(excludepath=py._dir)
|
ntraceback = ntraceback.cut(excludepath=py._pydir)
|
||||||
traceback = ntraceback.filter()
|
traceback = ntraceback.filter()
|
||||||
return traceback
|
return traceback
|
||||||
|
|
||||||
|
|
|
@ -318,7 +318,7 @@ class TmpTestdir:
|
||||||
assert hasattr(py.cmdline, cmdlinename), cmdlinename
|
assert hasattr(py.cmdline, cmdlinename), cmdlinename
|
||||||
source = ("import sys ; sys.path.insert(0, %r); "
|
source = ("import sys ; sys.path.insert(0, %r); "
|
||||||
"import py ; py.cmdline.%s()" %
|
"import py ; py.cmdline.%s()" %
|
||||||
(str(py._dir.dirpath()), cmdlinename))
|
(str(py._pydir.dirpath()), cmdlinename))
|
||||||
return (sys.executable, "-c", source,)
|
return (sys.executable, "-c", source,)
|
||||||
|
|
||||||
def runpython(self, script):
|
def runpython(self, script):
|
||||||
|
@ -329,7 +329,7 @@ class TmpTestdir:
|
||||||
|
|
||||||
def _getsysprepend(self):
|
def _getsysprepend(self):
|
||||||
if not self.request.config.getvalue("toolsonpath"):
|
if not self.request.config.getvalue("toolsonpath"):
|
||||||
s = "import sys ; sys.path.insert(0, %r) ; " % str(py._dir.dirpath())
|
s = "import sys ; sys.path.insert(0, %r) ; " % str(py._pydir.dirpath())
|
||||||
else:
|
else:
|
||||||
s = ""
|
s = ""
|
||||||
return s
|
return s
|
||||||
|
|
|
@ -174,7 +174,7 @@ class ReSTSyntaxTest(py.test.collect.Item):
|
||||||
'to the py package') % (text,)
|
'to the py package') % (text,)
|
||||||
relpath = '/'.join(text.split('/')[1:])
|
relpath = '/'.join(text.split('/')[1:])
|
||||||
if check:
|
if check:
|
||||||
pkgroot = py._impldir
|
pkgroot = py._pydir
|
||||||
abspath = pkgroot.join(relpath)
|
abspath = pkgroot.join(relpath)
|
||||||
assert pkgroot.join(relpath).check(), (
|
assert pkgroot.join(relpath).check(), (
|
||||||
'problem with linkrole :source:`%s`: '
|
'problem with linkrole :source:`%s`: '
|
||||||
|
|
|
@ -112,7 +112,7 @@ class TestTraceback_f_g_h:
|
||||||
def test_traceback_cut_excludepath(self, testdir):
|
def test_traceback_cut_excludepath(self, testdir):
|
||||||
p = testdir.makepyfile("def f(): raise ValueError")
|
p = testdir.makepyfile("def f(): raise ValueError")
|
||||||
excinfo = py.test.raises(ValueError, "p.pyimport().f()")
|
excinfo = py.test.raises(ValueError, "p.pyimport().f()")
|
||||||
basedir = py._impldir
|
basedir = py._pydir
|
||||||
newtraceback = excinfo.traceback.cut(excludepath=basedir)
|
newtraceback = excinfo.traceback.cut(excludepath=basedir)
|
||||||
assert len(newtraceback) == 1
|
assert len(newtraceback) == 1
|
||||||
assert newtraceback[0].frame.code.path == p
|
assert newtraceback[0].frame.code.path == p
|
||||||
|
|
|
@ -59,7 +59,7 @@ class TestDistOptions:
|
||||||
def test_getrsyncdirs(self, testdir):
|
def test_getrsyncdirs(self, testdir):
|
||||||
config = testdir.parseconfigure('--rsyncdir=' + str(testdir.tmpdir))
|
config = testdir.parseconfigure('--rsyncdir=' + str(testdir.tmpdir))
|
||||||
roots = config.getrsyncdirs()
|
roots = config.getrsyncdirs()
|
||||||
assert len(roots) == 1 + len(py._pydirs)
|
assert len(roots) == 1 + 1 # pylib itself
|
||||||
assert testdir.tmpdir in roots
|
assert testdir.tmpdir in roots
|
||||||
|
|
||||||
def test_getrsyncdirs_with_conftest(self, testdir):
|
def test_getrsyncdirs_with_conftest(self, testdir):
|
||||||
|
@ -71,7 +71,7 @@ class TestDistOptions:
|
||||||
""")
|
""")
|
||||||
config = testdir.parseconfigure(testdir.tmpdir, '--rsyncdir=y', '--rsyncdir=z')
|
config = testdir.parseconfigure(testdir.tmpdir, '--rsyncdir=y', '--rsyncdir=z')
|
||||||
roots = config.getrsyncdirs()
|
roots = config.getrsyncdirs()
|
||||||
assert len(roots) == 3 + len(py._pydirs)
|
assert len(roots) == 3 + 1 # pylib itself
|
||||||
assert py.path.local('y') in roots
|
assert py.path.local('y') in roots
|
||||||
assert py.path.local('z') in roots
|
assert py.path.local('z') in roots
|
||||||
assert testdir.tmpdir.join('x') in roots
|
assert testdir.tmpdir.join('x') in roots
|
||||||
|
|
|
@ -51,12 +51,19 @@ class TestGatewayManagerPopen:
|
||||||
hm.makegateways()
|
hm.makegateways()
|
||||||
assert len(hm.group) == 2
|
assert len(hm.group) == 2
|
||||||
for gw in hm.group:
|
for gw in hm.group:
|
||||||
gw.remote_exec = None
|
class pseudoexec:
|
||||||
|
args = []
|
||||||
|
def __init__(self, *args):
|
||||||
|
self.args.extend(args)
|
||||||
|
def waitclose(self):
|
||||||
|
pass
|
||||||
|
gw.remote_exec = pseudoexec
|
||||||
l = []
|
l = []
|
||||||
hm.rsync(source, notify=lambda *args: l.append(args))
|
hm.rsync(source, notify=lambda *args: l.append(args))
|
||||||
assert not l
|
assert not l
|
||||||
hm.exit()
|
hm.exit()
|
||||||
assert not len(hm.group)
|
assert not len(hm.group)
|
||||||
|
assert "sys.path.insert" in gw.remote_exec.args[0]
|
||||||
|
|
||||||
def test_rsync_popen_with_path(self, hook, mysetup):
|
def test_rsync_popen_with_path(self, hook, mysetup):
|
||||||
source, dest = mysetup.source, mysetup.dest
|
source, dest = mysetup.source, mysetup.dest
|
||||||
|
|
|
@ -66,6 +66,6 @@ def test_pytest_cmdline_main(testdir):
|
||||||
assert 1
|
assert 1
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
py.test.cmdline.main([__file__])
|
py.test.cmdline.main([__file__])
|
||||||
""" % (str(py._dir.dirpath())))
|
""" % (str(py._pydir.dirpath())))
|
||||||
import subprocess
|
import subprocess
|
||||||
subprocess.check_call([sys.executable, str(p)])
|
subprocess.check_call([sys.executable, str(p)])
|
||||||
|
|
|
@ -25,7 +25,7 @@ def test_virtual_module_identity():
|
||||||
assert local1 is local2
|
assert local1 is local2
|
||||||
|
|
||||||
def test_importall():
|
def test_importall():
|
||||||
base = py._impldir
|
base = py._pydir.join("impl")
|
||||||
nodirs = [
|
nodirs = [
|
||||||
base.join('test', 'testing', 'data'),
|
base.join('test', 'testing', 'data'),
|
||||||
base.join('path', 'gateway',),
|
base.join('path', 'gateway',),
|
||||||
|
|
Loading…
Reference in New Issue