Python Testing Tutorial

This tutorial helps you to learn automated testing in Python 3 using the pytest framework.

Moby Dick

Goal: Counting Words in Moby Dick

Captain Ahab was vicious because Moby Dick, the white whale, had bitten off his leg. So the captain set sail for a hunt. For months he was searching the sea for the white whale. The captain finally attacked the whale with a harpoon. Unimpressed, the whale devoured captain, crew and ship. The whale won.

tick marks while counting words

Herman Melville's book “Moby Dick” describes the epic fight between the captain of a whaling ship and a whale. In the book, the whale wins by eating most of the other characters. But does he also win by being mentioned more often?

In this course, you will test a program that analyzes the text of Melville's book.


clone the repository:

git clone

make mobydick/ importable:

export PYTHONPATH=$PYTHONPATH:/home/kristian/projects/python_testing_tutorial




Sources for this tutorial:


Feedback and comments are welcome at:

© 2018 Magdalena & Kristian Rother

Released under the conditions of a Creative Commons Attribution License 4.0.


Kristian Rother, Magdalena Rother, Daniel Szoska

Dr. Kristian Rother

I am a professional Python trainer, developer and author based in Berlin. I believe everybody can learn programming.

Contact me via:
+49 176 3052 4691


I felt that the course was well-planned to meet the needs of the group.

B. Dharmalingam, GGL Giessen

See also