Basic
Code should have a set of automated tests that allow you to design new code and modify existing code while verifying that everything continues to work correctly.
Introduction
To write a program, you need to test that it works.
Project setup
Create a new project and install the required testing dependencies:
uv init test
cd test
uv add --dev pytestAssert
Create the file test.py:
=
=
The old way to test code was to do a “print” and check that the result displayed on screen is what you expected.
HelloInstead of doing a print and checking the screen, you can assert the expected result:
You're reading a preview.
Sign in to read the full article. Any account opens 4 free articles a month; students and teachers read their course pages without limit.
Sign in