Debian Codegraph @

hypothesis-python/tests/nocover/test_fancy_repr.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 hypothesis import strategies as st
12
13
14 def test_floats_is_floats():
15 assert repr(st.floats()) == "floats()"
16
17
18 def test_includes_non_default_values():
19 assert repr(st.floats(max_value=1.0)) == "floats(max_value=1.0)"
20
21
22 def foo(*args, **kwargs):
23 pass
24
25
26 # fmt: off
27 # The linebreaks here can force our lambda repr code into specific paths,
28 # so we tell Black to leave them as-is.
29
30
31 def test_builds_repr():
32 assert repr(st.builds(foo, st.just(1), x=st.just(10))) == \
33 'builds(foo, just(1), x=just(10))'
34
35
36 def test_map_repr():
37 assert repr(st.integers().map(abs)) == 'integers().map(abs)'
38 assert repr(st.integers().map(lambda x: x * 2)) == \
39 'integers().map(lambda x: x * 2)'
40
41
42 def test_filter_repr():
43 assert repr(st.integers().filter(lambda x: x != 3)) == \
44 'integers().filter(lambda x: x != 3)'
45
46
47 def test_flatmap_repr():
48 assert repr(st.integers().flatmap(lambda x: st.booleans())) == \
49 'integers().flatmap(lambda x: st.booleans())'