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+ (parametrising your tests) #8

@alessandrofelder

Description

@alessandrofelder

pytest.mark.parametrize - Don't repeat yourself

Good practice in writing software is to avoid repetition in the code. A major reason for this is that if you want to make changes to the code in the future (e.g. we might want to add an argument to time_range like the timezone) you'd have to change this in several places in the code, which is more effort and increases the probability of forgetting to change one of the various places.

Most of the tests so far are very similar in structure. We can use pytest.mark.parametrize to get our tests DRY (Don't Repeat Yourself).

You will need the test function to accept parameters, for example called test_input and expected,
let the parametrize decorator know about it as its first argument and pass a list of pairs
with the values for each test.

Once you've done this, commit your changes to your repository with a meaningful commit message that also links to this issue.

> git add test_times.py
> git commit -m "<meaningful commit message here>. Answers UCL-RITS/ipls-workshop#8"

and push it to your fork.

> git push

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