added another funcarg example i had lying around

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-09-11 12:05:06 +02:00
parent 22c1ad9f7b
commit d4d0226058
3 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,7 @@
import py
def pytest_runtest_setup(item):
if isinstance(item, py.test.collect.Function):
mod = item.getparent(py.test.collect.Module).obj
if hasattr(mod, 'hello'):
py.builtin.print_("mod.hello", mod.hello)

View File

@ -0,0 +1,5 @@
hello = "world"
def test_func():
pass

View File

@ -0,0 +1,15 @@
# conftest.py
import py
def pytest_addoption(parser):
grp = parser.addgroup("testserver options")
grp.addoption("--url", action="store", default=None,
help="url for testserver")
def pytest_funcarg__url(request):
url = request.config.getvalue("url")
if url is None:
py.test.skip("need --url")
return url