# 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: collections.abc.Callable[[typing.Any], bool],
    settings: typing.Union[hypothesis.settings, None],
    random: typing.Union[random.Random, None],
    database_key: typing.Union[bytes, None],
) -> 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)
