February 2022
Intermediate to advanced
274 pages
6h 28m
English
The skip marker allows us to skip a test. Let’s say we’re thinking of adding the ability to sort in a future version of the Cards application, so we’d like to have the Card class support comparisons. We write a test for comparing Card objects with < like this:
| | from cards import Card |
| | |
| | |
| | def test_less_than(): |
| | c1 = Card("a task") |
| | c2 = Card("b task") |
| | assert c1 < c2 |
| | |
| | |
| | def test_equality(): |
| | c1 = Card("a task") |
| | c2 = Card("a task") |
| | assert c1 == c2 |
And it fails:
| | $ cd /path/to/code/ch6/builtins |
| | $ pytest --tb=short test_less_than.py |
| | ========================= test session starts ========================== |
| | collected 2 items ... |
Read now
Unlock full access