DEV Community

Eliyahou
Eliyahou

Posted on

Session 11: Testing with PyTest

pytest: helps you write better programs
The pytest framework makes it easy to write small, readable tests, and can scale to support complex functional testing for applications and libraries.
Image description

This code defines a simple test case using the pytest framework.
• The inc function takes a number x and returns x + 1.
• The test_answer function asserts that calling inc(3) should return 5.
• When this test is run using pytest, it will pass if the assertion is true and fail if the assertion is false.
• This is a simple example of how to use pytest to write and run tests for your code.

Top comments (0)