From ac5992f9a18c15d0bf7f989ebf1c2c47a076ac17 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Tue, 23 Nov 2010 20:27:12 -0600 Subject: [PATCH] some cajoling to get pytest.py to be found when it's not on path --- _pytest/pytester.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/_pytest/pytester.py b/_pytest/pytester.py index ab4d75528..c172948b0 100644 --- 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)