[py-svn] py-trunk commit ff1a6628cd01: fix some failures introduced by the last commit, document new "pytestconfig" funcarg
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Jan 1 21:07:33 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 1262376213 -3600
# Node ID ff1a6628cd01adb21a1992e737860aae23b88ba1
# Parent f2b15f840071de34272e3c3dac4bc678c1a54a56
fix some failures introduced by the last commit, document new "pytestconfig" funcarg
--- a/py/plugin/pytest_default.py
+++ b/py/plugin/pytest_default.py
@@ -29,6 +29,7 @@ def pytest_collect_file(path, parent):
return parent.Module(path, parent=parent)
def pytest_funcarg__pytestconfig(request):
+ """ the pytest config object with access to command line opts."""
return request.config
def pytest_collect_directory(path, parent):
--- a/testing/cmdline/test_cmdline.py
+++ b/testing/cmdline/test_cmdline.py
@@ -3,14 +3,13 @@ import sys, py
pytest_plugins = "pytest_pytester"
@py.test.mark.multi(name=[x for x in dir(py.cmdline) if x[0] != "_"])
-def test_cmdmain(name):
+def test_cmdmain(name, pytestconfig):
main = getattr(py.cmdline, name)
assert py.builtin.callable(main)
assert name[:2] == "py"
- scriptname = "py." + name[2:]
- if sys.platform == "win32":
- scriptname += ".exe"
- assert py.path.local.sysfind(scriptname), scriptname
+ if pytestconfig.getvalue("toolsonpath"):
+ scriptname = "py." + name[2:]
+ assert py.path.local.sysfind(scriptname), scriptname
class TestPyLookup:
def test_basic(self, testdir):
--- a/py/plugin/pytest_pytester.py
+++ b/py/plugin/pytest_pytester.py
@@ -338,8 +338,10 @@ class TmpTestdir:
def spawn_pytest(self, string, expect_timeout=10.0):
pexpect = py.test.importorskip("pexpect", "2.4")
+ if not self.request.config.getvalue("toolsonpath"):
+ py.test.skip("need --tools-on-path to run py.test script")
basetemp = self.tmpdir.mkdir("pexpect")
- invoke = "%s %s" % self._getpybinargs("py.test")
+ invoke = self._getpybinargs("py.test")[0]
cmd = "%s --basetemp=%s %s" % (invoke, basetemp, string)
child = pexpect.spawn(cmd, logfile=basetemp.join("spawn.out").open("w"))
child.timeout = expect_timeout
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,9 @@ Changes between 1.X and 1.1.1
- new option: --confcutdir=dir will make py.test only consider conftest
files that are relative to the specified dir.
+- new funcarg: "pytestconfig" is the pytest config object for access
+ to command line args and can now be easily used in a test.
+
- install 'py.test' and `py.which` with a ``-$VERSION`` suffix to
disambiguate between Python3, python2.X, Jython and PyPy installed versions.
More information about the pytest-commit
mailing list