More exact Exception tests
Some tests check for Exception.
- The code should raise a more exact exception type.
- The test should check for that.
- The test should use
matchto check that the exact expected exception is raised.
https://docs.pytest.org/en/7.1.x/how-to/assert.html#assertions-about-expected-exceptions