File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change
1
+ Do not raise ``UsageError `` when an imported package has a ``pytest_plugins.py `` child module.
Original file line number Diff line number Diff line change @@ -559,8 +559,8 @@ def _get_plugin_specs_as_list(specs):
559
559
which case it is returned as a list. Specs can also be `None` in which case an
560
560
empty list is returned.
561
561
"""
562
- if specs is not None :
563
- if isinstance (specs , str ):
562
+ if specs is not None and not isinstance ( specs , types . ModuleType ) :
563
+ if isinstance (specs , six . string_types ):
564
564
specs = specs .split ("," ) if specs else []
565
565
if not isinstance (specs , (list , tuple )):
566
566
raise UsageError (
Original file line number Diff line number Diff line change @@ -969,6 +969,20 @@ def test(): pass
969
969
assert r .ret == 0
970
970
971
971
972
+ def test_pytest_plugins_as_module (testdir ):
973
+ """Do not raise an error if pytest_plugins attribute is a module (#3899)"""
974
+ testdir .makepyfile (
975
+ ** {
976
+ "__init__.py" : "" ,
977
+ "pytest_plugins.py" : "" ,
978
+ "conftest.py" : "from . import pytest_plugins" ,
979
+ "test_foo.py" : "def test(): pass" ,
980
+ }
981
+ )
982
+ result = testdir .runpytest ()
983
+ result .stdout .fnmatch_lines ("* 1 passed in *" )
984
+
985
+
972
986
def test_deferred_hook_checking (testdir ):
973
987
"""
974
988
Check hooks as late as possible (#1821).
You can’t perform that action at this time.
0 commit comments