Merge pull request #4728 from nicoddemus/usage-error-module
Do not raise UsageError when "pytest_plugins" is a module
This commit is contained in:
commit
678dfaa6eb
|
@ -0,0 +1 @@
|
||||||
|
Do not raise ``UsageError`` when an imported package has a ``pytest_plugins.py`` child module.
|
|
@ -559,8 +559,8 @@ def _get_plugin_specs_as_list(specs):
|
||||||
which case it is returned as a list. Specs can also be `None` in which case an
|
which case it is returned as a list. Specs can also be `None` in which case an
|
||||||
empty list is returned.
|
empty list is returned.
|
||||||
"""
|
"""
|
||||||
if specs is not None:
|
if specs is not None and not isinstance(specs, types.ModuleType):
|
||||||
if isinstance(specs, str):
|
if isinstance(specs, six.string_types):
|
||||||
specs = specs.split(",") if specs else []
|
specs = specs.split(",") if specs else []
|
||||||
if not isinstance(specs, (list, tuple)):
|
if not isinstance(specs, (list, tuple)):
|
||||||
raise UsageError(
|
raise UsageError(
|
||||||
|
|
|
@ -969,6 +969,20 @@ def test_import_plugin_unicode_name(testdir):
|
||||||
assert r.ret == 0
|
assert r.ret == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_pytest_plugins_as_module(testdir):
|
||||||
|
"""Do not raise an error if pytest_plugins attribute is a module (#3899)"""
|
||||||
|
testdir.makepyfile(
|
||||||
|
**{
|
||||||
|
"__init__.py": "",
|
||||||
|
"pytest_plugins.py": "",
|
||||||
|
"conftest.py": "from . import pytest_plugins",
|
||||||
|
"test_foo.py": "def test(): pass",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
result = testdir.runpytest()
|
||||||
|
result.stdout.fnmatch_lines("* 1 passed in *")
|
||||||
|
|
||||||
|
|
||||||
def test_deferred_hook_checking(testdir):
|
def test_deferred_hook_checking(testdir):
|
||||||
"""
|
"""
|
||||||
Check hooks as late as possible (#1821).
|
Check hooks as late as possible (#1821).
|
||||||
|
|
Loading…
Reference in New Issue