Change8

pytest

Dev Tools

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing

Latest: 9.0.27 releases1 breaking changes12 common errorsView on GitHub

Release History

9.0.24 fixes1 feature
Dec 6, 2025

pytest 9.0.2 fixes several bugs, restores a broken private config attribute, updates documentation, and disables the terminal progress plugin by default for better terminal compatibility.

9.0.14 fixes
Nov 12, 2025

pytest 9.0.1 is a bug‑fix release that restores unittest.SkipTest support, disables the terminal progress plugin on iTerm2, corrects API reference types, and resolves a UserWarning on early Python 3.12/3.13 builds.

9.0.06 fixes8 features
Nov 8, 2025

pytest 9.0.0 adds experimental subtests, native TOML config, a global strict mode, terminal progress reporting, and several new configuration options while improving performance and error messages.

8.4.25 fixes
Sep 4, 2025

pytest 8.4.2 fixes several crashes (including console output style, decimal handling, and NumPy imports) and improves Python 3.14 compatibility.

8.4.13 fixes
Jun 18, 2025

pytest 8.4.1 fixes several bugs including TerminalReporter.isatty handling, restores the PytestReturnNotNoneWarning, and adds compatibility with Twisted 25+.

8.4.0Breaking10 features
Jun 2, 2025

pytest 8.4.0 introduces significant breaking changes—removing Python 3.8 support, enforcing stricter test return values, and disallowing yield tests—while adding powerful new features like RaisesGroup, enhanced xfail handling, and configurable output options.

8.3.55 fixes1 feature
Mar 2, 2025

pytest 8.3.5 delivers multiple bug fixes—including import‑mode crashes and libedit input handling—and re‑enables support for newer Towncrier versions when building Sphinx documentation.

Common Errors

ZeroDivisionError6 reports

A ZeroDivisionError in pytest usually arises from dividing by zero during a test, often within custom test logic or fixtures. To fix it, carefully inspect the traceback to pinpoint the faulty calculation and ensure the denominator is never zero by adding conditional checks or using appropriate error handling techniques to prevent the division. Provide a default value or use `pytest.skip` if a zero denominator renders the test meaningless.

ModuleNotFoundError3 reports

The "ModuleNotFoundError" in pytest usually indicates that a required Python package or module isn't installed or isn't in the Python path being used by pytest. To fix this, ensure that all necessary packages are installed, ideally using `pip install <package_name>`, and verify that your PYTHONPATH environment variable or pytest configuration correctly points to the location of the missing module if it's a custom one. You may need to activate the correct virtual environment if the module is installed there.

AssertionError3 reports

AssertionError in pytest usually indicates that a test's expected outcome doesn't match the actual result, signifying a failed assertion. To fix it, carefully examine the traceback to identify the specific assertion that failed and then adjust either the expected value or the code under test to ensure they align, or alternatively use `pytest.approx` to allow for small numerical differences. Debugging the test or the tested function is crucial to pinpoint the root cause of the discrepancy.

UncaughtCharmError1 report

The "UncaughtCharmError" in pytest, often occurring in pdb or traceback displays, typically arises from incorrect handling of terminal size or encoding changes during exception processing. To fix this, ensure that the `CHARM_DEBUG` environment variable is not set (or is set to an empty string) and that pytest's terminal output configurations are compatible with the execution environment; try running pytest with the `--no-header` flag to simplify terminal interactions.

AttributeError1 report

This error usually arises when accessing a non-existent attribute or method of an object within your pytest code (e.g., trying to read a nonexistent option added via pytest_addoption). Inspect the traceback to identify the problematic attribute and object. Ensure the attribute is correctly defined on the object or that the method is available; double-check for typos and correct option names passed to pytest_addoption.

UnicodeEncodeError1 report

UnicodeEncodeError in pytest often arises when the test output (including captured stdout/stderr, or parametrization values) contains characters that cannot be encoded using the default terminal encoding (like ASCII). Force pytest to use UTF-8 encoding by setting the `PYTHONIOENCODING=utf-8` environment variable before running pytest, or configure your system to use UTF-8 as the default encoding to ensure consistent encoding across environments.

Related Dev Tools Packages

Subscribe to Updates

Get notified when new versions are released

RSS Feed