Skip to content

Commit

Permalink
Merge pull request #2964 from rpuntaie/master
Browse files Browse the repository at this point in the history
fix issue #2920
  • Loading branch information
The-Compiler authored Nov 29, 2017
2 parents 191e8c6 + 5f1a733 commit 88ed1ab
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,4 @@ Wouter van Ackooy
Xuan Luong
Xuecong Liao
Zoltán Máté
Roland Puntaier
2 changes: 1 addition & 1 deletion _pytest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def import_plugin(self, modname):
# _pytest prefix.
assert isinstance(modname, (six.text_type, str)), "module name as text required, got %r" % modname
modname = str(modname)
if self.get_plugin(modname) is not None:
if self.is_blocked(modname) or self.get_plugin(modname) is not None:
return
if modname in builtin_plugins:
importspec = "_pytest." + modname
Expand Down
1 change: 1 addition & 0 deletions changelog/2920.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix issue about ``-p no:<plugin>`` having no effect.
2 changes: 1 addition & 1 deletion changelog/2949.trivial
Original file line number Diff line number Diff line change
@@ -1 +1 @@
iUpdate github "bugs" link in CONTRIBUTING.rst
Update github "bugs" link in CONTRIBUTING.rst
19 changes: 14 additions & 5 deletions testing/test_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import absolute_import, division, print_function
import sys
import py
import pytest

Expand Down Expand Up @@ -459,9 +460,12 @@ def load(self):
testdir.parseconfig()


def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch):
@pytest.mark.parametrize('block_it', [True, False])
def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch, block_it):
pkg_resources = pytest.importorskip("pkg_resources")

plugin_module_placeholder = object()

def my_iter(name):
assert name == "pytest11"

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

def load(self):
assert 0, "should not arrive here"
return plugin_module_placeholder

return iter([EntryPoint()])

monkeypatch.setattr(pkg_resources, 'iter_entry_points', my_iter)
config = testdir.parseconfig("-p", "no:mytestplugin")
plugin = config.pluginmanager.getplugin("mytestplugin")
assert plugin is None
args = ("-p", "no:mytestplugin") if block_it else ()
config = testdir.parseconfig(*args)
config.pluginmanager.import_plugin("mytestplugin")
if block_it:
assert "mytestplugin" not in sys.modules
assert config.pluginmanager.get_plugin('mytestplugin') is None
else:
assert config.pluginmanager.get_plugin('mytestplugin') is plugin_module_placeholder


def test_cmdline_processargs_simple(testdir):
Expand Down

0 comments on commit 88ed1ab

Please sign in to comment.