Skip to content

Commit

Permalink
Env var to skip loading of entrypoints.
Browse files Browse the repository at this point in the history
  • Loading branch information
jobh committed Jul 13, 2023
1 parent e763816 commit eee8dfe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RELEASE_TYPE: patch

Read environment variable HYPOTHESIS_NO_ENTRYPOINTS to
optionally skip loading of third-party plugin entrypoints.

10 changes: 6 additions & 4 deletions hypothesis-python/src/hypothesis/entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"""

import importlib.metadata
import os


def get_entry_points():
Expand All @@ -29,7 +30,8 @@ def get_entry_points():


def run():
for entry in get_entry_points(): # pragma: no cover
hook = entry.load()
if callable(hook):
hook()
if not os.environ.get("HYPOTHESIS_NO_ENTRYPOINTS"):
for entry in get_entry_points(): # pragma: no cover
hook = entry.load()
if callable(hook):
hook()
6 changes: 5 additions & 1 deletion hypothesis-python/tests/cover/test_lazy_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# 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/.

import os
import subprocess
import sys

Expand Down Expand Up @@ -44,4 +45,7 @@ def test_hypothesis_does_not_import_test_runners(tmp_path):
# See https://github.com/HypothesisWorks/hypothesis/pull/2204
fname = tmp_path / "test.py"
fname.write_text(SHOULD_NOT_IMPORT_TEST_RUNNERS, encoding="utf-8")
subprocess.check_call([sys.executable, str(fname)])
subprocess.check_call(
[sys.executable, str(fname)],
env=os.environ | {"HYPOTHESIS_NO_ENTRYPOINTS": "1"},
)

0 comments on commit eee8dfe

Please sign in to comment.