Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions testing/pytest/test_employee_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import pytest
from employee import Employee

# seeded at import time so parametrize decorator gets deterministic values (avoid )
# without seed, random.randint() produces different values each run (flaky tests)
_rng = random.Random(42)
_random_test_cases = [(_rng.randint(0, 100),) * 2 for _ in range(9)]


# pytest doesn't require TestCase to inherit from anything
class EmployeeTestCase:
Expand Down Expand Up @@ -40,15 +45,7 @@ def test_pay(employee):
(100, 100),
(1999, 1999),
(2022, 2022),
tuple([random.randint(0, 100)] * 2),
tuple([random.randint(0, 100)] * 2),
tuple([random.randint(0, 100)] * 2),
tuple([random.randint(0, 100)] * 2),
tuple([random.randint(0, 100)] * 2),
tuple([random.randint(0, 100)] * 2),
tuple([random.randint(0, 100)] * 2),
tuple([random.randint(0, 100)] * 2),
tuple([random.randint(0, 100)] * 2),
*_random_test_cases,
],
)
def test_very_simple(given_value, expected_value):
Expand Down
Loading