Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-10402

Never use assertRaises(Exception), always test a specific exception

    Details

    • Templates:

      Description

      I found 67 instances in the stack where we have a unittest that does assertRaises(Exception. This is bad, as demonstrated by GetPackageDirTestCase not failing when we switched to pybind11 and the raised exception went from NotFoundError to RuntimeError: assertRaises should be testing for a very specific condition that causes a very specific exception to be raised, it should never test for any exception, as something else could go wrong and you'd never know.

      We need to fix all of the cases of this in the stack so that they test for a specific exception, and also update the unittest developer docs to state that assertRaises needs to have a specific exception.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Parejkoj John Parejko
                Watchers:
                Jim Bosch, John Parejko, Jonathan Sick, Russell Owen, Simon Krughoff
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Summary Panel