From f760b105efa12ebc14adccda3c840ad3a61936ef Mon Sep 17 00:00:00 2001 From: Gleb Nikonorov Date: Sat, 6 Jun 2020 11:05:32 -0400 Subject: [PATCH] Touchup pre-PR --- changelog/7305.feature.rst | 3 +++ doc/en/reference.rst | 22 ++++++++++++---------- src/_pytest/config/__init__.py | 5 ----- 3 files changed, 15 insertions(+), 15 deletions(-) create mode 100644 changelog/7305.feature.rst diff --git a/changelog/7305.feature.rst b/changelog/7305.feature.rst new file mode 100644 index 000000000..cf5a48c6e --- /dev/null +++ b/changelog/7305.feature.rst @@ -0,0 +1,3 @@ +A new INI key `require_plugins` has been added that allows the user to specify a list of plugins required for pytest to run. + +The `--strict-config` flag can be used to treat these warnings as errors. diff --git a/doc/en/reference.rst b/doc/en/reference.rst index d84d9d405..1f1f2c423 100644 --- a/doc/en/reference.rst +++ b/doc/en/reference.rst @@ -1561,6 +1561,18 @@ passed multiple times. The expected format is ``name=value``. For example:: See :ref:`change naming conventions` for more detailed examples. +.. confval:: require_plugins + + A space separated list of plugins that must be present for pytest to run. + If any one of the plugins is not found, emit a warning. + If pytest is run with ``--strict-config`` exceptions are raised in place of warnings. + + .. code-block:: ini + + [pytest] + require_plugins = pluginA pluginB pluginC + + .. confval:: testpaths @@ -1604,13 +1616,3 @@ passed multiple times. The expected format is ``name=value``. For example:: [pytest] xfail_strict = True - - -.. confval:: required_plugins - - A space seperated list of plugins that must be present for pytest to run - - .. code-block:: ini - - [pytest] - require_plugins = pluginA pluginB pluginC diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 83878a486..7d077d297 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1090,11 +1090,6 @@ class Config: self._emit_warning_or_fail("Unknown config ini key: {}\n".format(key)) def _validate_plugins(self) -> None: - # so iterate over all required plugins and see if pluginmanager hasplugin - # NOTE: This also account for -p no: ( e.g: -p no:celery ) - # raise ValueError(self._parser._inidict['requiredplugins']) - # raise ValueError(self.getini("requiredplugins")) - # raise ValueError(self.pluginmanager.hasplugin('debugging')) for plugin in self.getini("require_plugins"): if not self.pluginmanager.hasplugin(plugin): self._emit_warning_or_fail(