diff --git a/example/assertion/global_testmodule_config/conftest.py b/example/assertion/global_testmodule_config/conftest.py new file mode 100644 index 000000000..74bbcedcb --- /dev/null +++ b/example/assertion/global_testmodule_config/conftest.py @@ -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) diff --git a/example/assertion/global_testmodule_config/test_hello.py b/example/assertion/global_testmodule_config/test_hello.py new file mode 100644 index 000000000..882e36acd --- /dev/null +++ b/example/assertion/global_testmodule_config/test_hello.py @@ -0,0 +1,5 @@ + +hello = "world" + +def test_func(): + pass diff --git a/example/funcarg/urloption/conftest.py b/example/funcarg/urloption/conftest.py new file mode 100644 index 000000000..439bcf569 --- /dev/null +++ b/example/funcarg/urloption/conftest.py @@ -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 +