fix some failures introduced by the last commit, document new "pytestconfig" funcarg

--HG--
branch : trunk
This commit is contained in:
holger krekel 2010-01-01 21:03:33 +01:00
parent f8b5951103
commit 47df1e16b6
4 changed files with 11 additions and 6 deletions

View File

@ -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.

View File

@ -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):

View File

@ -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

View File

@ -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):