pytest 8.0.0 was released on 17-Jan-2024, and I’m pretty excited about it.

I’m not going to cover all fo the changes, I’ll just highlight a few.
For full set of changes, see the pytest changelog:

Version Compatibility

  • Dropped support for Python 3.7, as it reached EOL last June.

Features and Improvements

Improved Diffs

Improved diffs that pytest prints when an assertion fails, including:

  • Very verbose -vv is a colored diff, instead of a big chunk of red.
  • Python code in error reports is now syntax-highlighted as Python.
  • The sections in the error reports are now better separated.
  • Diff for standard library container types are improved.
  • Added more comprehensive set assertion rewrites for comparisons other than equality ==, with the following operations now providing better failure messages: !=, <=, >=, <, and >.

Improvements to -r for xfailures and xpasses

  • Report tracebacks for xfailures when -rx is set.
  • Report captured output for xpasses when -rX is set.
  • For xpasses, add - in summary between test name and reason, to match how xfail is displayed.
  • This one was important to me. Massively helps when checking/debugging xfail/xpass outcomes in CI. Thanks to Fabian Sturm, Bruno Oliviera, and Ran Benita for help to get this release.

More improvements

  • Separate control For Assertion Verbosity
  • Additional Support For Exception Groups and __notes__
  • Improved Documentation

Breaking Changes

  • Lots of Collection Changes. In this version we’ve made several breaking changes to pytest’s collection phase, particularly around how filesystem directories and Python packages are collected, fixing deficiencies and allowing for cleanups and improvements to pytest’s internals. A deprecation period for these changes was not possible.

Bug Fixes

  • Too many to list. I think this is going to be a pretty solid release right out of the gate.

Check out the full changelog for all the juicy details.

And then upgrade and try it out! pip install -U pytest