February 2022
Intermediate to advanced
274 pages
6h 28m
English
Another way we can use multiple fixtures is just to use more than one in either a function or a fixture. As an example, we can put some pre-canned tasks together to test with as a fixture:
| | @pytest.fixture(scope="session") |
| | def some_cards(): |
| | """List of different Card objects""" |
| | return [ |
| | cards.Card("write book", "Brian", "done"), |
| | cards.Card("edit book", "Katie", "done"), |
| | cards.Card("write 2nd edition", "Brian", "todo"), |
| | cards.Card("edit 2nd edition", "Katie", "todo"), |
| | ] |
Then we can use both empty_db and some_cards in a test:
| | def test_add_some(cards_db, some_cards): |
| | expected_count = len(some_cards) |
| | for c |
Read now
Unlock full access