Debian Codegraph @

hypothesis-python/tests/conjecture/test_shrinking_interface.py

raw
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 from random import Random
12
13 from hypothesis.internal.conjecture.shrinking import Integer
14
15 from tests.common.utils import capture_out
16
17
18 def test_debug_output():
19 with capture_out() as o:
20 Integer.shrink(10, lambda x: True, debug=True, random=Random(0))
21
22 assert "initial=10" in o.getvalue()
23 assert "shrinking to 0" in o.getvalue()
24
25
26 def test_includes_name_in_repr_if_set():
27 assert (
28 repr(Integer(10, lambda x: True, name="hi there", random=Random(0)))
29 == "Integer('hi there', initial=10, current=10)"
30 )
31
32
33 def test_normally_contains_no_space_for_name():
34 assert (
35 repr(Integer(10, lambda x: True, random=Random(0)))
36 == "Integer(initial=10, current=10)"
37 )