Overview

pytest 8.0, released on January 28, 2024, fixes warning stack levels and improves the -p no: option to disable plugins.

Main Features

Warning stack level

Warnings emitted by pytest now point to the test code line, not to pytest internals. Debugging is more intuitive.

python
import warnings
import pytest

def test_deprecation():
    # Warning now points to this line
    warnings.warn('old usage', DeprecationWarning)

# pytest -W error::DeprecationWarning
# Traceback now points to test_deprecation

Improved -p no: option

The -p no:plugin option disables a plugin at startup. In 8.0, resolution is more reliable and works with short names.

python
# Disable plugins at launch
# pytest -p no:cacheprovider -p no:warnings

# In pyproject.toml
# [tool.pytest.ini_options]
# addopts = "-p no:cacheprovider"

# pytest --co -q  # check active plugins

Sources