From 00097df5cdc383315e020039233cd8e7562aa316 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 22 Jan 2020 13:04:30 +0100 Subject: [PATCH] tests: add test_plugin_loading_order Ref: https://github.com/pytest-dev/pytest/pull/6443 --- testing/test_config.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/testing/test_config.py b/testing/test_config.py index 498cbf7eb..cc54e5b23 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -670,6 +670,32 @@ def test_disable_plugin_autoload(testdir, monkeypatch, parse_args, 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): testdir.makeconftest( """