File: hypothesis_module_magic.txt

package info (click to toggle)
python-hypothesis 6.138.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,272 kB
  • sloc: python: 62,853; ruby: 1,107; sh: 253; makefile: 41; javascript: 6
file content (134 lines) | stat: -rw-r--r-- 4,046 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# This test code was written by the `hypothesis.extra.ghostwriter` module
# and is provided under the Creative Commons Zero public domain dedication.

import collections.abc
import datetime
import hypothesis
import random
import typing
from collections.abc import Hashable
from hypothesis import given, settings, strategies as st


@given(condition=st.from_type(object))
def test_fuzz_assume(condition: object) -> None:
    hypothesis.assume(condition=condition)


@given(value=st.text(), payload=st.one_of(st.floats(), st.integers(), st.text()))
def test_fuzz_event(value: str, payload: typing.Union[str, int, float]) -> None:
    hypothesis.event(value=value, payload=payload)


@given(
    specifier=st.from_type(st.SearchStrategy),
    condition=st.functions(like=lambda *a, **k: None, returns=st.booleans()),
    settings=st.from_type(typing.Optional[hypothesis.settings]),
    random=st.one_of(st.none(), st.randoms()),
    database_key=st.one_of(st.none(), st.binary()),
)
def test_fuzz_find(
    specifier: st.SearchStrategy,
    condition: typing.Callable[[typing.Any], bool],
    settings: typing.Optional[hypothesis.settings],
    random: typing.Optional[random.Random],
    database_key: typing.Optional[bytes],
) -> None:
    hypothesis.find(
        specifier=specifier,
        condition=condition,
        settings=settings,
        random=random,
        database_key=database_key,
    )


@given(f=st.from_type(object))
def test_fuzz_is_hypothesis_test(f: object) -> None:
    hypothesis.is_hypothesis_test(f=f)


@given(value=st.from_type(object))
def test_fuzz_note(value: object) -> None:
    hypothesis.note(value=value)


@given(r=st.randoms())
def test_fuzz_register_random(r: random.Random) -> None:
    hypothesis.register_random(r=r)


@given(version=st.text(), blob=st.binary())
def test_fuzz_reproduce_failure(version: str, blob: bytes) -> None:
    hypothesis.reproduce_failure(version=version, blob=blob)


@given(seed=st.from_type(Hashable))
def test_fuzz_seed(seed: collections.abc.Hashable) -> None:
    hypothesis.seed(seed=seed)


@given(
    parent=st.none(),
    max_examples=st.just(not_set),
    derandomize=st.just(not_set),
    database=st.just(not_set),
    verbosity=st.just(not_set),
    phases=st.just(not_set),
    stateful_step_count=st.just(not_set),
    report_multiple_bugs=st.just(not_set),
    suppress_health_check=st.just(not_set),
    deadline=st.just(not_set),
    print_blob=st.just(not_set),
    backend=st.just(not_set),
)
def test_fuzz_settings(
    parent: typing.Optional[hypothesis.settings],
    max_examples: int,
    derandomize: bool,
    database,
    verbosity: hypothesis.Verbosity,
    phases,
    stateful_step_count: int,
    report_multiple_bugs: bool,
    suppress_health_check,
    deadline: typing.Union[int, float, datetime.timedelta, None],
    print_blob: bool,
    backend: str,
) -> None:
    hypothesis.settings(
        parent=parent,
        max_examples=max_examples,
        derandomize=derandomize,
        database=database,
        verbosity=verbosity,
        phases=phases,
        stateful_step_count=stateful_step_count,
        report_multiple_bugs=report_multiple_bugs,
        suppress_health_check=suppress_health_check,
        deadline=deadline,
        print_blob=print_blob,
        backend=backend,
    )


@given(name=st.text())
def test_fuzz_settings_get_profile(name: str) -> None:
    hypothesis.settings.get_profile(name=name)


@given(name=st.text())
def test_fuzz_settings_load_profile(name: str) -> None:
    hypothesis.settings.load_profile(name=name)


@given(name=st.text(), parent=st.from_type(typing.Optional[hypothesis.settings]))
def test_fuzz_settings_register_profile(
    name: str, parent: typing.Optional[hypothesis.settings]
) -> None:
    hypothesis.settings.register_profile(name=name, parent=parent)


@given(observation=st.one_of(st.floats(), st.integers()), label=st.text())
def test_fuzz_target(observation: typing.Union[int, float], label: str) -> None:
    hypothesis.target(observation=observation, label=label)