Skip to content

Commit b8a1e1f

Browse files
committed
We only ever report strings now
1 parent 1cc458c commit b8a1e1f

File tree

3 files changed

+6
-26
lines changed

3 files changed

+6
-26
lines changed

hypothesis-python/RELEASE.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
RELEASE_TYPE: patch
2+
3+
Minor internal-only cleanups to some error-handling and reporting code.

hypothesis-python/src/hypothesis/reporting.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
99
# obtain one at https://mozilla.org/MPL/2.0/.
1010

11-
import inspect
12-
1311
from hypothesis._settings import Verbosity, settings
1412
from hypothesis.internal.compat import escape_unicode_characters
1513
from hypothesis.utils.dynamicvariables import DynamicVariable
@@ -37,14 +35,6 @@ def current_verbosity():
3735
return settings.default.verbosity
3836

3937

40-
def to_text(textish):
41-
if inspect.isfunction(textish):
42-
textish = textish()
43-
if isinstance(textish, bytes):
44-
textish = textish.decode()
45-
return textish
46-
47-
4838
def verbose_report(text):
4939
if current_verbosity() >= Verbosity.verbose:
5040
base_report(text)
@@ -61,4 +51,5 @@ def report(text):
6151

6252

6353
def base_report(text):
64-
current_reporter()(to_text(text))
54+
assert isinstance(text, str), f"unexpected non-str {text=}"
55+
current_reporter()(text)

hypothesis-python/tests/cover/test_reporting.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,12 @@
1515

1616
from hypothesis import given, reporting
1717
from hypothesis._settings import Verbosity, settings
18-
from hypothesis.reporting import debug_report, report, verbose_report
18+
from hypothesis.reporting import debug_report, verbose_report
1919
from hypothesis.strategies import integers
2020

2121
from tests.common.utils import capture_out
2222

2323

24-
def test_can_print_bytes():
25-
with capture_out() as o:
26-
with reporting.with_reporter(reporting.default):
27-
report(b"hi")
28-
assert o.getvalue() == "hi\n"
29-
30-
3124
def test_prints_output_by_default():
3225
@given(integers())
3326
def test_int(x):
@@ -77,10 +70,3 @@ def test_can_report_when_system_locale_is_ascii(monkeypatch):
7770
with open(write, "w", encoding="ascii") as write:
7871
monkeypatch.setattr(sys, "stdout", write)
7972
reporting.default("☃")
80-
81-
82-
def test_can_report_functions():
83-
with capture_out() as out:
84-
report(lambda: "foo")
85-
86-
assert out.getvalue().strip() == "foo"

0 commit comments

Comments
 (0)