pluginmanager.consider_preparse: add exclude_only kwarg (#6443)

Plugins specified with ``-p`` are now loaded after internal plugins, which
results in their hooks being called *before* the internal ones.

This makes the ``-p`` behavior consistent with ``PYTEST_PLUGINS``.

* fix/adjust test_disable_plugin_autoload
* adjust test_plugin_loading_order
This commit is contained in:
Daniel Hahler
2020-02-03 14:10:54 +01:00
committed by GitHub
parent 8ec4d03c91
commit 75714ee707
4 changed files with 21 additions and 8 deletions
+12 -1
View File
@@ -659,6 +659,13 @@ def test_disable_plugin_autoload(testdir, monkeypatch, parse_args, should_load):
class PseudoPlugin:
x = 42
attrs_used = []
def __getattr__(self, name):
assert name == "__loader__"
self.attrs_used.append(name)
return object()
def distributions():
return (Distribution(),)
@@ -668,6 +675,10 @@ def test_disable_plugin_autoload(testdir, monkeypatch, parse_args, should_load):
config = testdir.parseconfig(*parse_args)
has_loaded = config.pluginmanager.get_plugin("mytestplugin") is not None
assert has_loaded == should_load
if should_load:
assert PseudoPlugin.attrs_used == ["__loader__"]
else:
assert PseudoPlugin.attrs_used == []
def test_plugin_loading_order(testdir):
@@ -676,7 +687,7 @@ def test_plugin_loading_order(testdir):
"""
def test_terminal_plugin(request):
import myplugin
assert myplugin.terminal_plugin == [True, True]
assert myplugin.terminal_plugin == [False, True]
""",
**{
"myplugin": """