pytest
noun
say it: “PY-test” /ˈpaɪˌtɛst/
The most popular tool for testing Python code: tests are plain functions whose names start with test_, each checking a result with assert.
What is pytest?
pytest is the most popular tool for testing Python code. Tests are plain functions that start with test_ and use a simple assert.
# test_cart.py (run with: pytest)
def cart_total(prices):
return sum(prices)
def test_cart_total():
assert cart_total([5, 10]) == 15
In a sentence
- “Running pytest found and ran all twelve tests in the tests folder.”
- “pytest showed the expected and actual totals side by side when the test failed.”
Level: Journeyman · More Python terms at this level
Updated