[py-svn] py-trunk commit b7acb4d619f9: refine rsyncing and internal dir/transferal handling: don't transfer roots in a popen- no-chdir situation and only use one py._pydir everywhere

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Jan 11 14:31:30 CET 2010


# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview/
# User holger krekel <holger at merlinux.eu>
# Date 1263216650 -3600
# Node ID b7acb4d619f9e4713814df6d1a6fe0512d717b25
# Parent 085f5be42cb97cc7bf999aca6479aa1f2eb17d6f
refine rsyncing and internal dir/transferal handling: don't transfer roots in a popen- no-chdir situation and only use one py._pydir everywhere

--- a/py/impl/test/dist/gwmanage.py
+++ b/py/impl/test/dist/gwmanage.py
@@ -3,7 +3,7 @@
 """
 
 import py
-import sys, os
+import sys, os.path
 import execnet
 from execnet.gateway_base import RemoteError
 
@@ -35,7 +35,12 @@ class GatewayManager:
         gateways = []
         for gateway in self.group:
             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
             if spec not in seen:
                 def finished():

--- a/py/impl/test/config.py
+++ b/py/impl/test/config.py
@@ -269,21 +269,17 @@ class Config(object):
 
     def getrsyncdirs(self):
         config = self
-        roots = config.option.rsyncdir
+        candidates = [py._pydir] + config.option.rsyncdir
         conftestroots = config.getconftest_pathlist("rsyncdirs")
         if conftestroots:
-            roots.extend(conftestroots)
-        pydirs = [x.realpath() for x in py._pydirs]
-        roots = [py.path.local(root) for root in roots]
-        for root in roots:
+            candidates.extend(conftestroots)
+        roots = []
+        for root in candidates:
+            root = py.path.local(root).realpath()
             if not root.check():
                 raise config.Error("rsyncdir doesn't exist: %r" %(root,))
-            if pydirs is not None and root.basename in ("py", "_py"):
-                try:
-                    pydirs.remove(root) # otherwise it's a conflict
-                except ValueError: # we run as standalone py.test 
-                    pass
-        roots.extend(pydirs)
+            if root not in roots:
+                roots.append(root)
         return roots
 
 #

--- a/py/__init__.py
+++ b/py/__init__.py
@@ -19,9 +19,7 @@ py.apipkg.initpkg(__name__, dict(
     # access to all posix errno's as classes
     error = '.impl.error:error',
 
-    _impldir = '.impl._metainfo:impldir',
-    _dir = '.impl._metainfo:pydir',
-    _pydirs = '.impl._metainfo:pydirs',
+    _pydir = '.impl._metainfo:pydir',
     version = 'py:__version__', # backward compatibility
 
     cmdline = {

--- a/testing/code/test_excinfo.py
+++ b/testing/code/test_excinfo.py
@@ -112,7 +112,7 @@ class TestTraceback_f_g_h:
     def test_traceback_cut_excludepath(self, testdir):
         p = testdir.makepyfile("def f(): raise ValueError")
         excinfo = py.test.raises(ValueError, "p.pyimport().f()")
-        basedir = py._impldir
+        basedir = py._pydir
         newtraceback = excinfo.traceback.cut(excludepath=basedir)
         assert len(newtraceback) == 1
         assert newtraceback[0].frame.code.path == p

--- a/CHANGELOG
+++ b/CHANGELOG
@@ -50,6 +50,8 @@ Changes between 1.X and 1.1.1
 - change: pytest doctest plugin is now enabled by default and has a
   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 
   code failed and prevented the capturing setup code from running. 
 

--- a/testing/pytest/test_outcome.py
+++ b/testing/pytest/test_outcome.py
@@ -66,6 +66,6 @@ def test_pytest_cmdline_main(testdir):
             assert 1
         if __name__ == '__main__':
            py.test.cmdline.main([__file__])
-    """ % (str(py._dir.dirpath())))
+    """ % (str(py._pydir.dirpath())))
     import subprocess
     subprocess.check_call([sys.executable, str(p)])

--- a/py/impl/test/collect.py
+++ b/py/impl/test/collect.py
@@ -257,7 +257,7 @@ class Collector(Node):
             path = self.fspath 
             ntraceback = traceback.cut(path=self.fspath)
             if ntraceback == traceback:
-                ntraceback = ntraceback.cut(excludepath=py._dir)
+                ntraceback = ntraceback.cut(excludepath=py._pydir)
             traceback = ntraceback.filter()
         return traceback 
 

--- a/py/plugin/pytest_pytester.py
+++ b/py/plugin/pytest_pytester.py
@@ -318,7 +318,7 @@ class TmpTestdir:
             assert hasattr(py.cmdline, cmdlinename), cmdlinename
             source = ("import sys ; sys.path.insert(0, %r); "
                       "import py ; py.cmdline.%s()" % 
-                (str(py._dir.dirpath()), cmdlinename))
+                (str(py._pydir.dirpath()), cmdlinename))
             return (sys.executable, "-c", source,)
 
     def runpython(self, script):
@@ -329,7 +329,7 @@ class TmpTestdir:
 
     def _getsysprepend(self):
         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:
             s = ""
         return s

--- a/testing/plugin/test_pytest_default.py
+++ b/testing/plugin/test_pytest_default.py
@@ -59,7 +59,7 @@ class TestDistOptions:
     def test_getrsyncdirs(self, testdir):
         config = testdir.parseconfigure('--rsyncdir=' + str(testdir.tmpdir))
         roots = config.getrsyncdirs()
-        assert len(roots) == 1 + len(py._pydirs)
+        assert len(roots) == 1 + 1 # pylib itself
         assert testdir.tmpdir in roots
 
     def test_getrsyncdirs_with_conftest(self, testdir):
@@ -71,7 +71,7 @@ class TestDistOptions:
         """)
         config = testdir.parseconfigure(testdir.tmpdir, '--rsyncdir=y', '--rsyncdir=z')
         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('z') in roots 
         assert testdir.tmpdir.join('x') in roots 

--- a/py/impl/_metainfo.py
+++ b/py/impl/_metainfo.py
@@ -1,9 +1,2 @@
-
 import py
-
 pydir = py.path.local(py.__file__).dirpath()
-impldir = pydir.join("impl")
-
-# list of all directories beloging to py
-assert impldir.relto(pydir)
-pydirs = [pydir]

--- a/testing/test_py_imports.py
+++ b/testing/test_py_imports.py
@@ -25,7 +25,7 @@ def test_virtual_module_identity():
     assert local1 is local2
 
 def test_importall():
-    base = py._impldir
+    base = py._pydir.join("impl")
     nodirs = [
         base.join('test', 'testing', 'data'),
         base.join('path', 'gateway',),

--- a/bin-for-dist/makepluginlist.py
+++ b/bin-for-dist/makepluginlist.py
@@ -128,7 +128,7 @@ class RestWriter:
 
 class PluginOverview(RestWriter):
     def makerest(self, config):
-        plugindir = py._dir.join('plugin')
+        plugindir = py._pydir.join('plugin')
         for cat, specs in plugins:
             pluginlist = specs.split()
             self.h1(cat)

--- a/py/plugin/pytest_restdoc.py
+++ b/py/plugin/pytest_restdoc.py
@@ -174,7 +174,7 @@ class ReSTSyntaxTest(py.test.collect.Ite
                                             'to the py package') % (text,)
             relpath = '/'.join(text.split('/')[1:])
             if check:
-                pkgroot = py._impldir
+                pkgroot = py._pydir
                 abspath = pkgroot.join(relpath)
                 assert pkgroot.join(relpath).check(), (
                         'problem with linkrole :source:`%s`: '

--- a/testing/pytest/dist/test_gwmanage.py
+++ b/testing/pytest/dist/test_gwmanage.py
@@ -51,12 +51,19 @@ class TestGatewayManagerPopen:
         hm.makegateways()
         assert len(hm.group) == 2
         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 = []
         hm.rsync(source, notify=lambda *args: l.append(args))
         assert not l
         hm.exit()
         assert not len(hm.group) 
+        assert "sys.path.insert" in gw.remote_exec.args[0] 
 
     def test_rsync_popen_with_path(self, hook, mysetup):
         source, dest = mysetup.source, mysetup.dest 

--- a/py/impl/test/pycollect.py
+++ b/py/impl/test/pycollect.py
@@ -246,7 +246,7 @@ class FunctionMixin(PyobjMixin):
             if ntraceback == traceback:
                 ntraceback = ntraceback.cut(path=path)
                 if ntraceback == traceback:
-                    ntraceback = ntraceback.cut(excludepath=py._dir)
+                    ntraceback = ntraceback.cut(excludepath=py._pydir)
             traceback = ntraceback.filter()
         return traceback



More information about the pytest-commit mailing list