Broken test for duplicate error codes
Closed this issue · 3 comments
Issue
The test that checks whether there are any duplicate error codes never fails.
The TOR203 error code is defined three times and the test still passes:
https://github.com/pytorch-labs/torchfix/blob/main/torchfix/visitors/vision/singleton_import.py#L9
Root cause
The test itself checks if it has already seen the TorchError
object, not the specific error code:
https://github.com/pytorch-labs/torchfix/blob/main/tests/test_torchfix.py#L68
Because the object is initialised three times, the objects are distinct.
Solution
The test should check on the error code and the TorchError should only be initialised once in singleton import.
As a fix I'd like to directly address #6, by improving the TorchError data structure. (Already got the code)
TOR203 used three times in https://github.com/pytorch-labs/torchfix/blob/main/torchfix/visitors/vision/singleton_import.py#L9 is totally expected.
The test is to prevent different visitors to use the same code accidentally. Using the same code with slightly different messages in the same visitor is fine, otherwise there will be not enough error codes soon (and also some messages are dynamic).
But the test itself seems to be broken indeed.