February 2022
Intermediate to advanced
274 pages
6h 28m
English
Sometimes you might want to parametrize using data structures or objects as values. Let’s start with a string value parametrization from Chapter 5, Parametrization, and modify it to use Cards objects.
Here’s the function parametrization we used earlier in Chapter 5:
| | @pytest.mark.parametrize("start_state", ["done", "in prog", "todo"]) |
| | def test_finish(cards_db, start_state): |
| | c = Card("write a book", state=start_state) |
| | index = cards_db.add_card(c) |
| | cards_db.finish(index) |
| | card = cards_db.get_card(index) |
| | assert card.state == "done" |
This code includes one parameter, start_state, with string values statically listed in the parametrize() decorator.
This results in test node names that ...
Read now
Unlock full access