Intro to Pytest
docs.pytest.org·4w·
Discuss: DEV
Preview
Report Post

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.

PyPI package name: pytest

A quick example

# content of test_sample.py
def inc(x):
return x + 1


def test_answer():
assert inc(3) == 5

To execute it:

$ pytest
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 1 item

test_sample.py F                                                     [100%]

==========...

Similar Posts

Loading similar posts...