@@ -460,9 +460,12 @@ def load(self):
460
460
testdir .parseconfig ()
461
461
462
462
463
- 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 ):
464
465
pkg_resources = pytest .importorskip ("pkg_resources" )
465
466
467
+ plugin_module_placeholder = object ()
468
+
466
469
def my_iter (name ):
467
470
assert name == "pytest11"
468
471
@@ -478,14 +481,19 @@ class EntryPoint(object):
478
481
dist = Dist ()
479
482
480
483
def load (self ):
481
- assert 0 , "should not arrive here"
484
+ return plugin_module_placeholder
482
485
483
486
return iter ([EntryPoint ()])
484
487
485
488
monkeypatch .setattr (pkg_resources , 'iter_entry_points' , my_iter )
486
- config = testdir .parseconfig ("-p" , "no:mytestplugin" )
489
+ args = ("-p" , "no:mytestplugin" ) if block_it else ()
490
+ config = testdir .parseconfig (* args )
487
491
config .pluginmanager .import_plugin ("mytestplugin" )
488
- assert "mytestplugin" not in sys .modules
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
489
497
490
498
491
499
def test_cmdline_processargs_simple (testdir ):
0 commit comments