fix issue358 -- introduce new pytest_load_initial_conftests hook and make capturing initialization use it, relying on a new (somewhat internal) parser.parse_known_args() method.

This also addresses issue359 -- plugins like pytest-django could implement a pytest_load_initial_conftests hook like the capture plugin.
This commit is contained in:
holger krekel
2013-09-30 13:14:16 +02:00
parent 4b709037ab
commit db6f347db6
7 changed files with 80 additions and 35 deletions

View File

@@ -335,3 +335,18 @@ def test_notify_exception(testdir, capfd):
out, err = capfd.readouterr()
assert not err
def test_load_initial_conftest_last_ordering(testdir):
from _pytest.config import get_plugin_manager
pm = get_plugin_manager()
class My:
def pytest_load_initial_conftests(self):
pass
m = My()
pm.register(m)
l = pm.listattr("pytest_load_initial_conftests")
assert l[-1].__module__ == "_pytest.capture"
assert l[-2] == m.pytest_load_initial_conftests
assert l[-3].__module__ == "_pytest.config"