Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Exercise 2+ (negative tests) #9

Open
alessandrofelder opened this issue Apr 28, 2021 · 0 comments
Open

Exercise 2+ (negative tests) #9

alessandrofelder opened this issue Apr 28, 2021 · 0 comments

Comments

@alessandrofelder
Copy link
Collaborator

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant