logo

... pytest.


Testing your code is a good idea because it usually leads to great improvements. There's many libraries in python that will help with testing but a favourable on called pytest. In this series of videos we demonstrate how the use it.


Episode Notes

The new test_blackjack.py file looks like this;

import pytest 

from blackjack import card_score

@pytest.mark.parametrize("cards,score", [('JK', 20), ('KKK', 0), ('AA', 12), ('AK', 21)])
def test_simple_usecase(cards, score):
    assert card_score(cards) == score

We hope you agree it is better this way.


Feedback? See an issue? Feel free to mention it here.

If you want to be kept up to date, consider getting the newsletter.