Skip to content

Commit 456925b

Browse files
authored
Merge pull request #2395 from RonnyPfannschmidt/consider-all-modules
Consider all modules
2 parents b6125d9 + a92e397 commit 456925b

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ Changes
8181
* fix `#2308`_: When using both ``--lf`` and ``--ff``, only the last failed tests are run.
8282
Thanks `@ojii`_ for the PR.
8383

84+
* fix `#2391`_: consider pytest_plugins on all plugin modules
85+
Thansks `@RonnyPfannschmidt`_ for the PR.
8486

8587
Bug Fixes
8688
---------
@@ -114,8 +116,9 @@ Bug Fixes
114116
.. _#2166: https://github.com/pytest-dev/pytest/pull/2166
115117
.. _#2147: https://github.com/pytest-dev/pytest/issues/2147
116118
.. _#2208: https://github.com/pytest-dev/pytest/issues/2208
117-
.. _#2228: https://github.com/pytest-dev/pytest/issues/2228
119+
.. _#2228: https://github.com/pytest-dev/pytest/issues/2228
118120
.. _#2308: https://github.com/pytest-dev/pytest/issues/2308
121+
.. _#2391: https://github.com/pytest-dev/pytest/issues/2391
119122

120123

121124
3.0.8 (unreleased)

_pytest/config.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
import py
1010
# DON't import pytest here because it causes import cycle troubles
11-
import sys, os
11+
import sys
12+
import os
1213
import _pytest._code
1314
import _pytest.hookspec # the extension point definitions
1415
import _pytest.assertion
@@ -252,6 +253,9 @@ def register(self, plugin, name=None):
252253
if ret:
253254
self.hook.pytest_plugin_registered.call_historic(
254255
kwargs=dict(plugin=plugin, manager=self))
256+
257+
if isinstance(plugin, types.ModuleType):
258+
self.consider_module(plugin)
255259
return ret
256260

257261
def getplugin(self, name):
@@ -396,8 +400,7 @@ def consider_pluginarg(self, arg):
396400
self.import_plugin(arg)
397401

398402
def consider_conftest(self, conftestmodule):
399-
if self.register(conftestmodule, name=conftestmodule.__file__):
400-
self.consider_module(conftestmodule)
403+
self.register(conftestmodule, name=conftestmodule.__file__)
401404

402405
def consider_env(self):
403406
self._import_plugin_specs(os.environ.get("PYTEST_PLUGINS"))
@@ -441,7 +444,6 @@ def import_plugin(self, modname):
441444
else:
442445
mod = sys.modules[importspec]
443446
self.register(mod, modname)
444-
self.consider_module(mod)
445447

446448

447449
def _get_plugin_specs_as_list(specs):

0 commit comments

Comments
 (0)