Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #2920 #2964

Merged
merged 8 commits into from
Nov 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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