Debian Codegraph @

hypothesis-python/tests/ghostwriter/recorded/hypothesis_module_magic.txt

raw
1 # This test code was written by the `hypothesis.extra.ghostwriter` module
2 # and is provided under the Creative Commons Zero public domain dedication.
3
4 import collections.abc
5 import datetime
6 import hypothesis
7 import random
8 import typing
9 from collections.abc import Hashable
10 from hypothesis import given, settings, strategies as st
11
12
13 @given(condition=st.from_type(object))
14 def test_fuzz_assume(condition: object) -> None:
15 hypothesis.assume(condition=condition)
16
17
18 @given(value=st.text(), payload=st.one_of(st.floats(), st.integers(), st.text()))
19 def test_fuzz_event(value: str, payload: typing.Union[str, int, float]) -> None:
20 hypothesis.event(value=value, payload=payload)
21
22
23 @given(
24 specifier=st.from_type(st.SearchStrategy),
25 condition=st.functions(like=lambda *a, **k: None, returns=st.booleans()),
26 settings=st.from_type(typing.Optional[hypothesis.settings]),
27 random=st.one_of(st.none(), st.randoms()),
28 database_key=st.one_of(st.none(), st.binary()),
29 )
30 def test_fuzz_find(
31 specifier: st.SearchStrategy,
32 condition: collections.abc.Callable[[typing.Any], bool],
33 settings: typing.Union[hypothesis.settings, None],
34 random: typing.Union[random.Random, None],
35 database_key: typing.Union[bytes, None],
36 ) -> None:
37 hypothesis.find(
38 specifier=specifier,
39 condition=condition,
40 settings=settings,
41 random=random,
42 database_key=database_key,
43 )
44
45
46 @given(f=st.from_type(object))
47 def test_fuzz_is_hypothesis_test(f: object) -> None:
48 hypothesis.is_hypothesis_test(f=f)
49
50
51 @given(value=st.from_type(object))
52 def test_fuzz_note(value: object) -> None:
53 hypothesis.note(value=value)
54
55
56 @given(r=st.randoms())
57 def test_fuzz_register_random(r: random.Random) -> None:
58 hypothesis.register_random(r=r)
59
60
61 @given(version=st.text(), blob=st.binary())
62 def test_fuzz_reproduce_failure(version: str, blob: bytes) -> None:
63 hypothesis.reproduce_failure(version=version, blob=blob)
64
65
66 @given(seed=st.from_type(Hashable))
67 def test_fuzz_seed(seed: collections.abc.Hashable) -> None:
68 hypothesis.seed(seed=seed)
69
70
71 @given(
72 parent=st.none(),
73 max_examples=st.just(not_set),
74 derandomize=st.just(not_set),
75 database=st.just(not_set),
76 verbosity=st.just(not_set),
77 phases=st.just(not_set),
78 stateful_step_count=st.just(not_set),
79 report_multiple_bugs=st.just(not_set),
80 suppress_health_check=st.just(not_set),
81 deadline=st.just(not_set),
82 print_blob=st.just(not_set),
83 backend=st.just(not_set),
84 )
85 def test_fuzz_settings(
86 parent: typing.Optional[hypothesis.settings],
87 max_examples: int,
88 derandomize: bool,
89 database,
90 verbosity: hypothesis.Verbosity,
91 phases,
92 stateful_step_count: int,
93 report_multiple_bugs: bool,
94 suppress_health_check,
95 deadline: typing.Union[int, float, datetime.timedelta, None],
96 print_blob: bool,
97 backend: str,
98 ) -> None:
99 hypothesis.settings(
100 parent=parent,
101 max_examples=max_examples,
102 derandomize=derandomize,
103 database=database,
104 verbosity=verbosity,
105 phases=phases,
106 stateful_step_count=stateful_step_count,
107 report_multiple_bugs=report_multiple_bugs,
108 suppress_health_check=suppress_health_check,
109 deadline=deadline,
110 print_blob=print_blob,
111 backend=backend,
112 )
113
114
115 @given(name=st.text())
116 def test_fuzz_settings_get_profile(name: str) -> None:
117 hypothesis.settings.get_profile(name=name)
118
119
120 @given(name=st.text())
121 def test_fuzz_settings_load_profile(name: str) -> None:
122 hypothesis.settings.load_profile(name=name)
123
124
125 @given(name=st.text(), parent=st.from_type(typing.Optional[hypothesis.settings]))
126 def test_fuzz_settings_register_profile(
127 name: str, parent: typing.Optional[hypothesis.settings]
128 ) -> None:
129 hypothesis.settings.register_profile(name=name, parent=parent)
130
131
132 @given(observation=st.one_of(st.floats(), st.integers()), label=st.text())
133 def test_fuzz_target(observation: typing.Union[int, float], label: str) -> None:
134 hypothesis.target(observation=observation, label=label)