tests: add test_plugin_loading_order

Ref: https://github.com/pytest-dev/pytest/pull/6443
This commit is contained in:
Daniel Hahler 2020-01-22 13:04:30 +01:00
parent 10e243d206
commit 00097df5cd
1 changed files with 26 additions and 0 deletions

View File

@ -670,6 +670,32 @@ def test_disable_plugin_autoload(testdir, monkeypatch, parse_args, should_load):
assert has_loaded == should_load assert has_loaded == should_load
def test_plugin_loading_order(testdir):
"""Test order of plugin loading with `-p`."""
p1 = testdir.makepyfile(
"""
def test_terminal_plugin(request):
import myplugin
assert myplugin.terminal_plugin == [True, True]
""",
**{
"myplugin": """
terminal_plugin = []
def pytest_configure(config):
terminal_plugin.append(bool(config.pluginmanager.get_plugin("terminalreporter")))
def pytest_sessionstart(session):
config = session.config
terminal_plugin.append(bool(config.pluginmanager.get_plugin("terminalreporter")))
"""
}
)
testdir.syspathinsert()
result = testdir.runpytest("-p", "myplugin", str(p1))
assert result.ret == 0
def test_cmdline_processargs_simple(testdir): def test_cmdline_processargs_simple(testdir):
testdir.makeconftest( testdir.makeconftest(
""" """