Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/hypothesis/reporting.py: 45%
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
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
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/.
11import inspect
13from hypothesis._settings import Verbosity, settings
14from hypothesis.internal.compat import escape_unicode_characters
15from hypothesis.utils.dynamicvariables import DynamicVariable
18def default(value):
19 try:
20 print(value)
21 except UnicodeEncodeError:
22 print(escape_unicode_characters(value))
25reporter = DynamicVariable(default)
28def current_reporter():
29 return reporter.value
32def with_reporter(new_reporter):
33 return reporter.with_value(new_reporter)
36def current_verbosity():
37 return settings.default.verbosity
40def to_text(textish):
41 if inspect.isfunction(textish):
42 textish = textish()
43 if isinstance(textish, bytes):
44 textish = textish.decode()
45 return textish
48def verbose_report(text):
49 if current_verbosity() >= Verbosity.verbose:
50 base_report(text)
53def debug_report(text):
54 if current_verbosity() >= Verbosity.debug:
55 base_report(text)
58def report(text):
59 if current_verbosity() >= Verbosity.normal:
60 base_report(text)
63def base_report(text):
64 current_reporter()(to_text(text))