Merge pull request #2964 from rpuntaie/master

fix issue #2920
This commit is contained in:
Florian Bruhin 2017-11-29 10:32:28 +01:00 committed by GitHub
commit 88ed1ab648
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 7 deletions

View File

@ -186,3 +186,4 @@ Wouter van Ackooy
Xuan Luong
Xuecong Liao
Zoltán Máté
Roland Puntaier

View File

@ -417,7 +417,7 @@ class PytestPluginManager(PluginManager):
# _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

1
changelog/2920.bugfix Normal file
View File

@ -0,0 +1 @@
Fix issue about ``-p no:<plugin>`` having no effect.

View File

@ -1 +1 @@
iUpdate github "bugs" link in CONTRIBUTING.rst
Update github "bugs" link in CONTRIBUTING.rst

View File

@ -1,4 +1,5 @@
from __future__ import absolute_import, division, print_function
import sys
import py
import pytest
@ -459,9 +460,12 @@ def test_setuptools_importerror_issue1479(testdir, monkeypatch):
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"
@ -477,14 +481,19 @@ def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch):
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):