Skip to content

Commit 88ed1ab

Browse files
authored
Merge pull request #2964 from rpuntaie/master
fix issue #2920
2 parents 191e8c6 + 5f1a733 commit 88ed1ab

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,4 @@ Wouter van Ackooy
186186
Xuan Luong
187187
Xuecong Liao
188188
Zoltán Máté
189+
Roland Puntaier

_pytest/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def import_plugin(self, modname):
417417
# _pytest prefix.
418418
assert isinstance(modname, (six.text_type, str)), "module name as text required, got %r" % modname
419419
modname = str(modname)
420-
if self.get_plugin(modname) is not None:
420+
if self.is_blocked(modname) or self.get_plugin(modname) is not None:
421421
return
422422
if modname in builtin_plugins:
423423
importspec = "_pytest." + modname

changelog/2920.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix issue about ``-p no:<plugin>`` having no effect.

changelog/2949.trivial

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
iUpdate github "bugs" link in CONTRIBUTING.rst
1+
Update github "bugs" link in CONTRIBUTING.rst

testing/test_config.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import absolute_import, division, print_function
2+
import sys
23
import py
34
import pytest
45

@@ -459,9 +460,12 @@ def load(self):
459460
testdir.parseconfig()
460461

461462

462-
def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch):
463+
@pytest.mark.parametrize('block_it', [True, False])
464+
def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch, block_it):
463465
pkg_resources = pytest.importorskip("pkg_resources")
464466

467+
plugin_module_placeholder = object()
468+
465469
def my_iter(name):
466470
assert name == "pytest11"
467471

@@ -477,14 +481,19 @@ class EntryPoint(object):
477481
dist = Dist()
478482

479483
def load(self):
480-
assert 0, "should not arrive here"
484+
return plugin_module_placeholder
481485

482486
return iter([EntryPoint()])
483487

484488
monkeypatch.setattr(pkg_resources, 'iter_entry_points', my_iter)
485-
config = testdir.parseconfig("-p", "no:mytestplugin")
486-
plugin = config.pluginmanager.getplugin("mytestplugin")
487-
assert plugin is None
489+
args = ("-p", "no:mytestplugin") if block_it else ()
490+
config = testdir.parseconfig(*args)
491+
config.pluginmanager.import_plugin("mytestplugin")
492+
if block_it:
493+
assert "mytestplugin" not in sys.modules
494+
assert config.pluginmanager.get_plugin('mytestplugin') is None
495+
else:
496+
assert config.pluginmanager.get_plugin('mytestplugin') is plugin_module_placeholder
488497

489498

490499
def test_cmdline_processargs_simple(testdir):

0 commit comments

Comments
 (0)