Skip to content

Commit

Permalink
feat(test): add the pytest-cases package and a simple example of how …
Browse files Browse the repository at this point in the history
…to use it
  • Loading branch information
jenstroeger committed Jan 29, 2025
1 parent 0eea8db commit 0392ece
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ hooks = [
test = [
"hypothesis >=6.21.0,<6.122.8",
"pytest >=7.2.0,<9.0.0",
"pytest-cases ==3.8.6",
"pytest-custom_exit_code ==0.3.0",
"pytest-cov ==6.0.0",
"pytest-doctestplus ==1.3.0",
Expand Down
11 changes: 9 additions & 2 deletions tests/test_something.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
"""Test the Something module. Add more tests here, as needed."""

from hypothesis import given, strategies
from pytest_cases import parametrize

from package.something import Something


@given(strategies.booleans())
def test_something(boolean: bool) -> None:
"""Test something here."""
def test_something_hypothesis(boolean: bool) -> None:
"""Test something here using Hypothesis."""
assert Something.do_something(boolean) is True


@parametrize("boolean", [True, False])
def test_something_cases(boolean: bool) -> None:
"""Test something here using Cases."""
assert Something.do_something(boolean) is True

0 comments on commit 0392ece

Please sign in to comment.