diff --git a/hypothesis-python/.coveragerc b/hypothesis-python/.coveragerc index baa88b2536..b5a21591f8 100644 --- a/hypothesis-python/.coveragerc +++ b/hypothesis-python/.coveragerc @@ -6,6 +6,7 @@ omit = **/extra/cli.py **/extra/django/*.py **/extra/ghostwriter.py + **/extra/pytestplugin.py **/internal/scrutineer.py **/utils/terminal.py diff --git a/hypothesis-python/RELEASE.rst b/hypothesis-python/RELEASE.rst index 5bc62a7a9c..7727d5ad9a 100644 --- a/hypothesis-python/RELEASE.rst +++ b/hypothesis-python/RELEASE.rst @@ -3,6 +3,3 @@ RELEASE_TYPE: minor This release modifies our :pypi:`pytest` plugin, to avoid importing Hypothesis and therefore triggering :ref:`Hypothesis' entry points ` for test suites where Hypothesis is installed but not actually used (:issue:`3140`). - -If you :ref:`manually load the plugin `, you'll need -to update the module name accordingly. diff --git a/hypothesis-python/docs/strategies.rst b/hypothesis-python/docs/strategies.rst index 25b76a3455..4918da61fc 100644 --- a/hypothesis-python/docs/strategies.rst +++ b/hypothesis-python/docs/strategies.rst @@ -189,8 +189,6 @@ And that's all it takes! package to be installed. -.. _disabling-pytest-plugin: - Interaction with :pypi:`pytest-cov` ----------------------------------- @@ -204,5 +202,5 @@ opting out of the pytest plugin entirely. Alternatively, you can ensure that Hy is loaded after coverage measurement is started by disabling the entrypoint, and loading our pytest plugin from your ``conftest.py`` instead:: - echo "pytest_plugins = ['_hypothesis_pytestplugin']\n" > tests/conftest.py + echo "pytest_plugins = ['hypothesis.extra.pytestplugin']\n" > tests/conftest.py pytest -p "no:hypothesispytest" ... diff --git a/hypothesis-python/src/hypothesis/extra/pytestplugin.py b/hypothesis-python/src/hypothesis/extra/pytestplugin.py new file mode 100644 index 0000000000..2f160a94cf --- /dev/null +++ b/hypothesis-python/src/hypothesis/extra/pytestplugin.py @@ -0,0 +1,24 @@ +# This file is part of Hypothesis, which may be found at +# https://github.com/HypothesisWorks/hypothesis/ +# +# Most of this work is copyright (C) 2013-2021 David R. MacIver +# (david@drmaciver.com), but it contains contributions by others. See +# CONTRIBUTING.rst for a full list of people who may hold copyright, and +# consult the git log if you need to determine who owns an individual +# contribution. +# +# This Source Code Form is subject to the terms of the Mozilla Public License, +# v. 2.0. If a copy of the MPL was not distributed with this file, You can +# obtain one at https://mozilla.org/MPL/2.0/. +# +# END HEADER + +""" +Stub for users who manually load our pytest plugin. + +The plugin implementation is now located in a top-level module outside the main +hypothesis tree, so that Pytest can load the plugin without thereby triggering +the import of Hypothesis itself (and thus loading our own plugins). +""" + +from _hypothesis_pytestplugin import * # noqa