Python Quest

Track 13 · Lesson 2 of 12

Writing tests with assert

Write test functions with assert, add helpful failure messages, and structure each test as arrange, act, assert.

About 35 minBeginner3 exercises

You will be able to

  • Write assert statements that compare an actual result with an expected value
  • Add a failure message to an assert that explains what went wrong
  • Organise each test function as arrange, act, assert
  • Recognise asserts that can never fail and fix them

Included with a Formula Quest membership

It has 3 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.

View Formula Quest memberships

Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.