-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Description
There are many cases where unittest.TestCase is extended today instead of our specialized common_utils.TestCase in our code base, like in many distributed tests, fx tests, and onnx tests:
https://github.com/pytorch/pytorch/search?q=Unittest.TestCase
Sometimes, this is intentional, but often times, I suspect it is accidental or due to oversight/unawareness. These test cases miss out on the customizations we place in https://github.com/pytorch/pytorch/blob/master/torch/testing/_internal/common_utils.py#L1307, which include:
- Not enjoying the functionality of pre-written wrappers
- The CI not being able to check and skip if they are a slow test
- The CI not being able to check and skip if they are disabled
To enforce this, we can check in run_tests() if the test is a vanilla unittest.TestCase and error when that is the case. This would capture the case where the test writer is trying to use all the features in common_utils.py but neglected to extend the right TestCase. This would also allow test classes that intend to use the vanilla TestCase to do so without being yelled at.
cc @seemethere @malfet @pytorch/pytorch-dev-infra