-
-
Notifications
You must be signed in to change notification settings - Fork 655
Closed
Description
Improve tests using pytest parametrize
The idea is to improve our testing code using pytest.mark.parametrize
.
Currently some tests are implemented as :
def test_something():
def _test(a):
# internal function doing some tests
# For example, a dummy check below
assert 0 < a < 5
a = 1
_test(a)
a = 2
_test(a, b, c)
We would like to implement that using pytest.mark.parametrize
:
@pytest.mark.parametrize("a", [1, 2])
def test_something(a):
# internal function doing some tests
# For example, a dummy check below
assert 0 < a < 5
Another example PR doing that for a test case: https://github.com/pytorch/ignite/pull/2521/files
What to do:
- Read CONTRIBUTING to see how to develop and execute a specific test: https://github.com/pytorch/ignite/blob/master/CONTRIBUTING.md#run-tests
- Explore test codebase and identify tests to improve. Please pay attention that some tests most probably can't be reimplemented with
pytest.mark.parametrize
as they can generated random data. Let's skip all_test_distrib_*
tests as they can be particularly complicated to port. - Once a test to improve is identified, comment out here about it and propose a draft code snippet of how you think to reimplement it using
pytest.mark.parametrize
. - In parallel, you can try to reimplement it locally and test if the new test is still passing. Please make sure not to modify test assertions to make test pass as your PR wont be accepted.
- Send a draft PR
Thanks!