You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I ran unit tests locally, 3 errors/failures were thrown because a new ADCPAM calibration filename had 1 underscore in it instead of 2 before the calibration date. The error messages printed did not point to the exact problem and suggested that there was a cascading failure that was not caught.
The problem is that within the method: asset-management/test/test_base.py > class: AssetManagementUnitTest > method: parse_cal_filename
a split statement that tries to split the filename by the double underscore within a try except block does not throw an exception when there aren't 2 underscores. It normally would return a list with 2 elements split by the 2 underscores, but instead, if the split function does not see the delimiter in a string, it returns the same string in a 1 element list. So instead of failing at the parse_cal_filename method, it fails outside of the method in the CalibrationFileUnitTest subclass when the method is called (here, here, and here). Instead it fails for ValueError where the output expects 2 items returned from the function but only one is returned. This then escapes the FileNameException exception clause and therefore does not accurately report the problem. Since the base function failed in 3 separate test functions, the single failure appears as 3.
Although it was relatively quick to figure out what the problem was, I recommend updating the parse_cal_filename method (and perhaps similar methods) to catch badly formed filenames by either checking that it splits the filename as expected, or perhaps using a regex to truly make sure a filename follows the intended format.
-Stuart
The text was updated successfully, but these errors were encountered:
When I ran unit tests locally, 3 errors/failures were thrown because a new ADCPAM calibration filename had 1 underscore in it instead of 2 before the calibration date. The error messages printed did not point to the exact problem and suggested that there was a cascading failure that was not caught.
The problem is that within the method:
asset-management/test/test_base.py > class:
AssetManagementUnitTest
> method:parse_cal_filename
a split statement that tries to split the filename by the double underscore within a try except block does not throw an exception when there aren't 2 underscores. It normally would return a list with 2 elements split by the 2 underscores, but instead, if the split function does not see the delimiter in a string, it returns the same string in a 1 element list. So instead of failing at the
parse_cal_filename
method, it fails outside of the method in theCalibrationFileUnitTest
subclass when the method is called (here, here, and here). Instead it fails forValueError
where the output expects 2 items returned from the function but only one is returned. This then escapes theFileNameException
exception clause and therefore does not accurately report the problem. Since the base function failed in 3 separate test functions, the single failure appears as 3.Although it was relatively quick to figure out what the problem was, I recommend updating the
parse_cal_filename
method (and perhaps similar methods) to catch badly formed filenames by either checking that it splits the filename as expected, or perhaps using a regex to truly make sure a filename follows the intended format.-Stuart
The text was updated successfully, but these errors were encountered: