Overview
pytest 6.2, released on January 26, 2021, improves test summaries and refines verbose mode for better report readability.
Main Features
Short test summary
The -r option lets you customize the summary displayed at the end of the session. You can filter by status: f (failed), s (skipped), x (xfailed), etc. The summary is more concise and readable.
python
# test_calculations.py
import pytest
def test_addition():
assert 2 + 2 == 4
def test_division():
assert 10 / 3 == pytest.approx(3.333, rel=1e-2)
@pytest.mark.skip(reason='Waiting for fix')
def test_future_feature():
pass
def test_failure():
assert 1 + 1 == 3 # will fail
# Run with custom summary:
# pytest -rfs -> show Failed + Skipped
# pytest -ra -> show all non-passed statuses
Verbose mode improvements
The --tb=short mode produces more compact tracebacks. The -v mode now displays the full path of each test and its result in a more structured way.
python
# test_users.py
import pytest
@pytest.fixture
def user():
return {'name': 'Smith', 'age': 30}
def test_name(user):
assert user['name'] == 'Smith'
def test_age(user):
assert user['age'] >= 18
# Verbose run with short tracebacks:
# pytest -v --tb=short
#
# test_users.py::test_name PASSED
# test_users.py::test_age PASSED
