Negative tests - Test that invalid inputs fail meaningfully and as expected
time_range may still work when t1 is before t0, but that may cause compute_overlap to work in unexpected ways.
Your job is to ensure calling time_range with an invalid input stops the code execution with a good error message for the user. This is an example of a "negative test".
- Write a test that tries to generate a time range for a date going backwards.
- Modify
time_range to produce an error (ValueError) with a meaningful message.
- You can do this using the line
raise ValueError("<message here>")
- Use
pytest.raises (See its documentation) to check that the code raises the expected error and error message.
- Commit, push and link to this issue, as you've done with the exercises.
What other similar tests could we add?