Skip to content

Commit

Permalink
test: move hypothesis settings to profile
Browse files Browse the repository at this point in the history
  • Loading branch information
hollandjg committed Feb 15, 2024
1 parent e6d0947 commit 2ee6486
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
10 changes: 8 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from hypothesis import Verbosity, settings
from hypothesis import HealthCheck, Verbosity, settings

settings.register_profile("ci", max_examples=1000)
settings.register_profile(
"ci",
verbosity=Verbosity.verbose,
max_examples=1000,
deadline=2000,
suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large],
)
settings.register_profile("debug", max_examples=10, verbosity=Verbosity.verbose)
6 changes: 1 addition & 5 deletions tests/test_state.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

import pandas as pd
from hypothesis import Verbosity, given, settings
from hypothesis import given
from pandas import DataFrame

from autora.state import StandardState
Expand All @@ -19,28 +19,24 @@


@given(variable_strategy(), serializer_dump_load_strategy)
@settings(verbosity=Verbosity.verbose)
def test_variable_serialize_deserialize(o: Variable, dump_load):
o_loaded = dump_load(o)
assert o == o_loaded


@given(variablecollection_strategy(), serializer_dump_load_strategy)
@settings(verbosity=Verbosity.verbose)
def test_variablecollection_serialize_deserialize(o: VariableCollection, dump_load):
o_loaded = dump_load(o)
assert o == o_loaded


@given(dataframe_strategy(), serializer_dump_load_strategy)
@settings(verbosity=Verbosity.verbose)
def test_dataframe_serialize_deserialize(o: DataFrame, dump_load):
o_loaded = dump_load(o)
o.equals(o_loaded)


@given(standard_state_strategy(), serializer_dump_load_strategy)
@settings(verbosity=Verbosity.verbose)
def test_state_serialize_deserialize(o: StandardState, dump_load):
o_loaded = dump_load(o)
assert o.variables == o_loaded.variables
Expand Down
6 changes: 1 addition & 5 deletions tests/test_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pandas as pd
import sklearn.dummy
import sklearn.linear_model
from hypothesis import Verbosity, given, settings
from hypothesis import given
from hypothesis import strategies as st
from hypothesis.extra import numpy as st_np
from hypothesis.extra import pandas as st_pd
Expand Down Expand Up @@ -154,7 +154,6 @@ def _name_label_units_strategy(
return name, label, units, covariate


@settings(verbosity=Verbosity.verbose)
@st.composite
def variable_boolean_strategy(draw, name=None, label=None, units=None, covariate=None):
name, label, units, covariate = draw(
Expand All @@ -178,7 +177,6 @@ def variable_boolean_strategy(draw, name=None, label=None, units=None, covariate
)


@settings(verbosity=Verbosity.verbose)
@given(variable_boolean_strategy())
def test_variable_boolean_strategy_creation(o):
assert o
Expand Down Expand Up @@ -605,7 +603,6 @@ def test_model_strategy_creation(o):
assert o


@settings(verbosity=Verbosity.verbose)
@st.composite
def standard_state_strategy(draw):
variable_collection: VariableCollection = draw(variablecollection_strategy())
Expand All @@ -631,7 +628,6 @@ def standard_state_strategy(draw):
return s


@settings(verbosity=Verbosity.verbose)
@given(standard_state_strategy())
def test_standard_state_strategy_creation(o):
assert o
Expand Down
3 changes: 1 addition & 2 deletions tests/test_variable.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from hypothesis import given, settings
from hypothesis import given
from hypothesis import strategies as st

from .test_serializer import serializer_dump_load_strategy
Expand All @@ -16,7 +16,6 @@
),
serializer_dump_load_strategy,
)
@settings(deadline=1000)
def test_variable_serialize_deserialize(o, dump_load):
o_loaded = dump_load(o)
assert o_loaded == o
1 change: 0 additions & 1 deletion tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def test_e2e_nominal(workflow_library_module):
st.booleans(),
st.booleans(),
)
@settings(verbosity=Verbosity.verbose, deadline=1000)
def test_e2e_serializers(workflow_library_module, serializer, verbose, debug):
"""Test a basic standard chain of CLI calls using a single serializer."""

Expand Down

0 comments on commit 2ee6486

Please sign in to comment.