# HG changeset patch -- Bitbucket.org
# Project pytest
# URL http://bitbucket.org/hpk42/pytest/overview
# User Benjamin Peterson <benja...@python.org>
# Date 1290565632 21600
# Node ID 0fb3d4517695c142c743c1702efd32015a158d02
# Parent  af0ac4661ead95d62747f34939a1e449a022200d
some cajoling to get pytest.py to be found when it's not on path

--- a/_pytest/pytester.py
+++ b/_pytest/pytester.py
@@ -17,6 +17,15 @@ def pytest_addoption(parser):
            help=("discover tools on PATH instead of going through py.cmdline.")
     )
 
+def pytest_configure(config):
+    # This might be called multiple times. Only take the first.
+    global _pytest_fullpath
+    import pytest
+    try:
+        _pytest_fullpath
+    except NameError:
+        _pytest_fullpath = os.path.abspath(pytest.__file__.rstrip("oc"))
+
 def pytest_funcarg___pytest(request):
     return PytestArg(request)
 
@@ -456,13 +465,10 @@ class TmpTestdir:
 
     def _getpybinargs(self, scriptname):
         if not self.request.config.getvalue("notoolsonpath"):
-            import pytest
-            script = pytest.__file__.rstrip("co")
-            assert script, "script %r not found" % scriptname
             # XXX we rely on script refering to the correct environment
             # we cannot use "(py.std.sys.executable,script)"
             # becaue on windows the script is e.g. a py.test.exe
-            return (py.std.sys.executable, script,)
+            return (py.std.sys.executable, _pytest_fullpath,)
         else:
             py.test.skip("cannot run %r with --no-tools-on-path" % scriptname)
_______________________________________________
py-svn mailing list
py-svn@codespeak.net
http://codespeak.net/mailman/listinfo/py-svn

Reply via email to