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

Exercise 2+ (negative tests) #9

@alessandrofelder

Description

@alessandrofelder

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions