Skip to content

Commit

Permalink
Unflake hypothesis tests
Browse files Browse the repository at this point in the history
Restrict hypothesis strategies generating interaction types and molecule names from using characters in the unicode classes Z (separators) and C (control characters).
  • Loading branch information
pckroon committed Jan 28, 2021
1 parent 6ccc2d2 commit d42a7c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion vermouth/tests/molecule_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def interaction_collection(draw, graph,
ninteraction_types = draw(st.integers(min_value=0, max_value=2))
for _ in range(ninteraction_types):
ninteractions = draw(st.integers(min_value=0, max_value=2))
type_name = draw(st.text())
type_name = draw(st.text(st.characters(blacklist_categories=('C', 'Z')), min_size=1))
if type_name not in result:
result[type_name] = []
for _ in range(ninteractions):
Expand Down
8 changes: 7 additions & 1 deletion vermouth/tests/test_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,13 @@ def test_interaction_sort(interactions, expected):
assert vermouth.molecule.Molecule.sort_interactions(interactions) == expected


@hypothesis.given(moltype=st.one_of(st.none(), st.text()), mol=random_molecule())
@hypothesis.given(
moltype=st.one_of(
st.none(),
st.text(st.characters(blacklist_categories=('C', 'Z')), min_size=1)
),
mol=random_molecule()
)
def test_str_method(mol, moltype):
"""
Test Molecule.__str__
Expand Down

0 comments on commit d42a7c6

Please sign in to comment.