# This test code was written by the `hypothesis.extra.ghostwriter` module
# and is provided under the Creative Commons Zero public domain dedication.

import datetime
import hypothesis
import hypothesis.strategies
import hypothesis.strategies._internal.strategies
import random
import typing
from hypothesis import given, settings, strategies as st
from hypothesis.strategies._internal.strategies import Ex
from random import Random


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


@given(value=st.text())
def test_fuzz_event(value: str) -> None:
    hypothesis.event(value=value)


@given(
    specifier=st.from_type(hypothesis.strategies.SearchStrategy),
    condition=st.functions(like=lambda *a, **k: None, returns=st.booleans()),
    settings=st.one_of(st.none(), st.builds(settings)),
    random=st.one_of(st.none(), st.builds(Random)),
    database_key=st.one_of(st.none(), st.binary()),
)
def test_fuzz_find(
    specifier: hypothesis.strategies.SearchStrategy[
        hypothesis.strategies._internal.strategies.Ex
    ],
    condition: typing.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(value=st.text())
def test_fuzz_note(value: str) -> None:
    hypothesis.note(value=value)


@given(r=st.builds(Random))
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(typing.Hashable))
def test_fuzz_seed(seed: typing.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),
)
def test_fuzz_settings(
    parent: typing.Union[hypothesis.settings, None],
    max_examples: int,
    derandomize: bool,
    database,
    verbosity,
    phases,
    stateful_step_count: int,
    report_multiple_bugs: bool,
    suppress_health_check,
    deadline: typing.Union[int, float, datetime.timedelta, None],
    print_blob: bool,
) -> 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,
    )


@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.one_of(st.none(), st.builds(settings)))
def test_fuzz_settings_register_profile(
    name: str, parent: typing.Union[hypothesis.settings, None]
) -> 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)
