[py-svn] py-trunk commit c85b3b8db30c: fix some "import py" test issues, and prevent "genscript" script from having dist-options
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sun Jan 10 21:50:01 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 1263152737 -3600
# Node ID c85b3b8db30cd5d814ede4c34cc3694dd77b1095
# Parent 92f94395f31c1e99a0db0300599e26f130b192d5
fix some "import py" test issues, and prevent "genscript" script from having dist-options
--- a/testing/plugin/test_pytest_capture.py
+++ b/testing/plugin/test_pytest_capture.py
@@ -250,10 +250,8 @@ class TestLoggingInteraction:
def test_capturing_and_logging_fundamentals(self, testdir):
# here we check a fundamental feature
- rootdir = str(py.path.local(py.__file__).dirpath().dirpath())
p = testdir.makepyfile("""
import sys, os
- sys.path.insert(0, %r)
import py, logging
if hasattr(os, 'dup'):
cap = py.io.StdCaptureFD(out=False, in_=False)
@@ -262,7 +260,7 @@ class TestLoggingInteraction:
logging.warn("hello1")
outerr = cap.suspend()
- print ("suspeneded and captured %%s" %% (outerr,))
+ print ("suspeneded and captured %s" % (outerr,))
logging.warn("hello2")
@@ -270,8 +268,8 @@ class TestLoggingInteraction:
logging.warn("hello3")
outerr = cap.suspend()
- print ("suspend2 and captured %%s" %% (outerr,))
- """ % rootdir)
+ print ("suspend2 and captured %s" % (outerr,))
+ """)
result = testdir.runpython(p)
assert result.stdout.fnmatch_lines([
"suspeneded and captured*hello1*",
--- a/py/plugin/pytest_default.py
+++ b/py/plugin/pytest_default.py
@@ -5,6 +5,8 @@ import py
try:
import execnet
+ if not py.path.local(py.__file__).check():
+ raise ImportError("")
except ImportError:
execnet = None
else:
--- a/testing/pytest/acceptance_test.py
+++ b/testing/pytest/acceptance_test.py
@@ -81,11 +81,11 @@ class TestGeneralUsage:
import py
assert hasattr(py.test, 'mark')
""")
- result = testdir._run(sys.executable, p)
+ result = testdir.runpython(p)
assert result.ret == 0
def test_pydoc(self, testdir):
- result = testdir._run(sys.executable, "-c", "import py ; help(py.test)")
+ result = testdir.runpython_c("import py ; help(py.test)")
assert result.ret == 0
s = result.stdout.str()
assert 'MarkGenerator' in s
--- a/testing/plugin/test_pytest_genscript.py
+++ b/testing/plugin/test_pytest_genscript.py
@@ -31,7 +31,7 @@ def test_rundist(testdir, standalone):
pass
""")
result = standalone.run(sys.executable, testdir, '-n', '3')
- assert result.ret == 0
- result.stdout.fnmatch_lines([
- "*1 passed*"
+ assert result.ret == 2
+ result.stderr.fnmatch_lines([
+ "*no such option*"
])
--- a/py/plugin/pytest_pytester.py
+++ b/py/plugin/pytest_pytester.py
@@ -321,7 +321,21 @@ class TmpTestdir:
return (sys.executable, "-c", source,)
def runpython(self, script):
- return self.run(py.std.sys.executable, script)
+ s = self._getsysprepend()
+ if s:
+ script.write(s + "\n" + script.read())
+ return self.run(sys.executable, script)
+
+ def _getsysprepend(self):
+ if not self.request.config.getvalue("toolsonpath"):
+ s = "import sys ; sys.path.insert(0, %r) ; " % str(py._dir.dirpath())
+ else:
+ s = ""
+ return s
+
+ def runpython_c(self, command):
+ command = self._getsysprepend() + command
+ return self.run(py.std.sys.executable, "-c", command)
def runpytest(self, *args):
p = py.path.local.make_numbered_dir(prefix="runpytest-",
More information about the pytest-commit
mailing list