August 2018
Beginner
160 pages
4h 8m
English
Using pytest, all you need to do to start writing tests is to create a new file named test_*.py and write test functions that start with test:
# contents of test_player_mechanics.py def test_player_hit(): player = create_player() assert player.health == 100 undead = create_undead() undead.hit(player) assert player.health == 80
To execute this test, simply execute pytest, passing the name of the file:
λ pytest test_player_mechanics.py
If you don't pass anything, pytest will look for all of the test files from the current directory recursively and execute them automatically.
Read now
Unlock full access