Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/hypothesis/entry_points.py: 71%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

7 statements  

1# This file is part of Hypothesis, which may be found at 

2# https://github.com/HypothesisWorks/hypothesis/ 

3# 

4# Copyright the Hypothesis Authors. 

5# Individual contributors are listed in AUTHORS.rst and the git log. 

6# 

7# This Source Code Form is subject to the terms of the Mozilla Public License, 

8# v. 2.0. If a copy of the MPL was not distributed with this file, You can 

9# obtain one at https://mozilla.org/MPL/2.0/. 

10 

11"""Run all functions registered for the "hypothesis" entry point. 

12 

13This can be used with `st.register_type_strategy` to register strategies for your 

14custom types, running the relevant code when *hypothesis* is imported instead of 

15your package. 

16""" 

17 

18import importlib.metadata 

19import os 

20 

21 

22def run() -> None: 

23 if os.environ.get("HYPOTHESIS_NO_PLUGINS"): 

24 return 

25 

26 for entry in importlib.metadata.entry_points( 

27 group="hypothesis" 

28 ): # pragma: no cover 

29 hook = entry.load() 

30 if callable(hook): 

31 hook()