File tree Expand file tree Collapse file tree 3 files changed +6
-26
lines changed Expand file tree Collapse file tree 3 files changed +6
-26
lines changed Original file line number Diff line number Diff line change
1
+ RELEASE_TYPE: patch
2
+
3
+ Minor internal-only cleanups to some error-handling and reporting code.
Original file line number Diff line number Diff line change 8
8
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
9
9
# obtain one at https://mozilla.org/MPL/2.0/.
10
10
11
- import inspect
12
-
13
11
from hypothesis ._settings import Verbosity , settings
14
12
from hypothesis .internal .compat import escape_unicode_characters
15
13
from hypothesis .utils .dynamicvariables import DynamicVariable
@@ -37,14 +35,6 @@ def current_verbosity():
37
35
return settings .default .verbosity
38
36
39
37
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
-
48
38
def verbose_report (text ):
49
39
if current_verbosity () >= Verbosity .verbose :
50
40
base_report (text )
@@ -61,4 +51,5 @@ def report(text):
61
51
62
52
63
53
def base_report (text ):
64
- current_reporter ()(to_text (text ))
54
+ assert isinstance (text , str ), f"unexpected non-str { text = } "
55
+ current_reporter ()(text )
Original file line number Diff line number Diff line change 15
15
16
16
from hypothesis import given , reporting
17
17
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
19
19
from hypothesis .strategies import integers
20
20
21
21
from tests .common .utils import capture_out
22
22
23
23
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
-
31
24
def test_prints_output_by_default ():
32
25
@given (integers ())
33
26
def test_int (x ):
@@ -77,10 +70,3 @@ def test_can_report_when_system_locale_is_ascii(monkeypatch):
77
70
with open (write , "w" , encoding = "ascii" ) as write :
78
71
monkeypatch .setattr (sys , "stdout" , write )
79
72
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"
You can’t perform that action at this time.
0 commit comments