Skip to content

Commit

Permalink
Add stub pytestplugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Nov 25, 2021
1 parent cfcf982 commit 221aa1a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions hypothesis-python/.coveragerc
Expand Up @@ -6,6 +6,7 @@ omit =
**/extra/cli.py
**/extra/django/*.py
**/extra/ghostwriter.py
**/extra/pytestplugin.py
**/internal/scrutineer.py
**/utils/terminal.py

Expand Down
3 changes: 0 additions & 3 deletions hypothesis-python/RELEASE.rst
Expand Up @@ -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 <entry-points>` for
test suites where Hypothesis is installed but not actually used (:issue:`3140`).

If you :ref:`manually load the plugin <disabling-pytest-plugin>`, you'll need
to update the module name accordingly.
4 changes: 1 addition & 3 deletions hypothesis-python/docs/strategies.rst
Expand Up @@ -189,8 +189,6 @@ And that's all it takes!
package to be installed.


.. _disabling-pytest-plugin:

Interaction with :pypi:`pytest-cov`
-----------------------------------

Expand All @@ -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" ...
24 changes: 24 additions & 0 deletions 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

0 comments on commit 221aa1a

Please sign in to comment.