-
Notifications
You must be signed in to change notification settings - Fork 27.7k
Request to import pytest in test/*.py #11578
Copy link
Copy link
Open
Labels
module: testsIssues related to tests (not the torch.testing module)Issues related to tests (not the torch.testing module)triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Metadata
Metadata
Assignees
Labels
module: testsIssues related to tests (not the torch.testing module)Issues related to tests (not the torch.testing module)triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Currently PyTorch uses the builtin
unittestmodule for testing. Would it be possible to add a dependency on pytest so developers can more easily write parametrized tests?While working on test/test_distributions.py, @neerajprad, @alicanb, and @fritzo have found it challenging to write heavily parametrized tests. As a result, test coverage suffers. By contrast in Pyro we use heavily parametrized tests using pytest, and our Pyro tests seem to catch many bugs that aren't caught in PyTorch's own tests (#9917, #9521, #9977, #10241).
In particular, I'd like to be able to gather xfailing tests in batch
and then mark xfailing parameters
pytest makes it easy to collect xfailing tests in batch (
pytest -v --tb=no) and to see the entire list of xfailing tests, and makes it easy to run xfailing tests to see which have started passing since the last time tests were run (pytest -v, orpytest --runxfail). In contrast,unittestfixtures typically parametrize via for loops and can report only a single failure on each run. (Apologies if I'm unaware of convenient functionality inunittest!)I think allowing usage of pytest in test/*.py could help improve PyTorch test coverage.
cc @mruberry