NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #24 most downloaded on PyPI
pytest: simple powerful testing with Python
Last release 3 months ago
19 Jun 2026
Ships fairly regularly
a new release about every 2 months
Nearly every release is documented
notes for 60 of the last 60 stable releases
1 version withdrawn
withdrawn after publishing
16 years old
192 releases · first in 2010
- fix issue214 - parse modules that contain special objects like e. g. flask’s request object which blows up on getattr access if no request is active
fix issue214 - parse modules that contain special objects like e. g. flask’s request object which blows up on getattr access if no request is active. thanks Thomas Waldmann.
fix issue213 - allow to parametrize with values like numpy arrays that do not support an eq operator
fix issue215 - split test_python.org into multiple files
fix issue148 - @unittest.skip on classes is now recognized and avoids calling setUpClass/tearDownClass, thanks Pavel Repin
fix issue209 - reintroduce python2.4 support by depending on newer pylib which re-introduced statement-finding for pre-AST interpreters
nose support: only call setup if it’s a callable, thanks Andrew Taumoefolau
fix issue219 - add py2.4-3.3 classifiers to TROVE list
in tracebacks ,* arg values are now shown next to normal arguments (thanks Manuel Jacob)
fix issue217 - support mock.patch with pytest’s fixtures - note that you need either mock-1.0.1 or the python3.3 builtin unittest.mock.
fix issue127 - improve documentation for pytest_addoption() and add a config.getoption(name) helper function for consistency.
One column per quarter.
- fix issue208 and fix issue29 use new py version to avoid long pauses when printing tracebacks in long modules
fix issue208 and fix issue29 use new py version to avoid long pauses when printing tracebacks in long modules
fix issue205 - conftests in subdirs customizing pytest_pycollect_makemodule and pytest_pycollect_makeitem now work properly
fix teardown-ordering for parametrized setups
fix issue127 - better documentation for pytest_addoption and related objects.
fix unittest behaviour: TestCase.runtest only called if there are test methods defined
improve trial support: don’t collect its empty unittest.TestCase.runTest() method
“python setup.py test” now works with pytest itself
fix/improve internal/packaging related bits:
exception message check of test_nose.py now passes on python33 as well
issue206 - fix test_assertrewrite.py to work when a global PYTHONDONTWRITEBYTECODE=1 is present
add tox.ini to pytest distribution so that ignore-dirs and others config bits are properly distributed for maintainers who run pytest-own tests
- fix issue202 - fix regression: using “self” from fixture functions now works as expected (it’s the same “self” instance that a test method which use
fix issue202 - fix regression: using “self” from fixture functions now works as expected (it’s the same “self” instance that a test method which uses the fixture sees)
skip pexpect using tests (test_pdb.py mostly) on freebsd* systems due to pexpect not supporting it properly (hanging)
link to web pages from –markers output which provides help for pytest.mark.* usage.
- fix issue202 - better automatic names for parametrized test functions
fix issue202 - better automatic names for parametrized test functions
fix issue139 - introduce @pytest.fixture which allows direct scoping and parametrization of funcarg factories.
fix issue198 - conftest fixtures were not found on windows32 in some circumstances with nested directory structures due to path manipulation issues
fix issue193 skip test functions with were parametrized with empty parameter sets
fix python3.3 compat, mostly reporting bits that previously depended on dict ordering
introduce re-ordering of tests by resource and parametrization setup which takes precedence to the usual file-ordering
fix issue185 monkeypatching time.time does not cause pytest to fail
fix issue172 duplicate call of pytest.fixture decoratored setup_module functions
fix junitxml=path construction so that if tests change the current working directory and the path is a relative path it is constructed correctly from the original current working dir.
fix “python setup.py test” example to cause a proper “errno” return
fix issue165 - fix broken doc links and mention stackoverflow for FAQ
catch unicode-issues when writing failure representations to terminal to prevent the whole session from crashing
fix xfail/skip confusion: a skip-mark or an imperative pytest.skip will now take precedence before xfail-markers because we can’t determine xfail/xpass status in case of a skip. see also: http://stackoverflow.com/questions/11105828/in-py-test-when-i-explicitly-skip-a-test-that-is-marked-as-xfail-how-can-i-get
always report installed 3rd party plugins in the header of a test run
fix issue160: a failing setup of an xfail-marked tests should be reported as xfail (not xpass)
fix issue128: show captured output when capsys/capfd are used
fix issue179: properly show the dependency chain of factories
pluginmanager.register(…) now raises ValueError if the plugin has been already registered or the name is taken
fix issue159: improve https://docs.pytest.org/en/6.0.1/faq.html especially with respect to the “magic” history, also mention pytest-django, trial and unittest integration.
make request.keywords and node.keywords writable. All descendant collection nodes will see keyword values. Keywords are dictionaries containing markers and other info.
fix issue 178: xml binary escapes are now wrapped in py.xml.raw
fix issue 176: correctly catch the builtin AssertionError even when we replaced AssertionError with a subclass on the python level
factory discovery no longer fails with magic global callables that provide no sane code object (mock.call for example)
fix issue 182: testdir.inprocess_run now considers passed plugins
fix issue 188: ensure sys.exc_info is clear on python2 before calling into a test
fix issue 191: add unittest TestCase runTest method support
fix issue 156: monkeypatch correctly handles class level descriptors
reporting refinements:
pytest_report_header now receives a “startdir” so that you can use startdir.bestrelpath(yourpath) to show nice relative path
allow plugins to implement both pytest_report_header and pytest_sessionstart (sessionstart is invoked first).
don’t show deselected reason line if there is none
py.test -vv will show all of assert comparisons instead of truncating
- fix error message for rewritten assertions involving the % operator
fix error message for rewritten assertions involving the % operator
fix issue 126: correctly match all invalid xml characters for junitxml binary escape
fix issue with unittest: now @unittest.expectedFailure markers should be processed correctly (you can also use @pytest.mark markers)
document integration with the extended distribute/setuptools test commands
fix issue 140: properly get the real functions of bound classmethods for setup/teardown_class
fix issue #141: switch from the deceased paste.pocoo.org to bpaste.net
fix issue #143: call unconfigure/sessionfinish always when configure/sessionstart where called
fix issue #144: better mangle test ids to junitxml classnames
upgrade distribute_setup.py to 0.6.27
- fix uploaded package to only include necessary files
fix uploaded package to only include necessary files
- fix issue101: wrong args to unittest.TestCase test function now produce better output
fix issue101: wrong args to unittest.TestCase test function now produce better output
fix issue102: report more useful errors and hints for when a test directory was renamed and some pyc/pycache remain
fix issue106: allow parametrize to be applied multiple times e.g. from module, class and at function level.
fix issue107: actually perform session scope finalization
don’t check in parametrize if indirect parameters are funcarg names
add chdir method to monkeypatch funcarg
fix crash resulting from calling monkeypatch undo a second time
fix issue115: make –collectonly robust against early failure (missing files/directories)
“-qq –collectonly” now shows only files and the number of tests in them
“-q –collectonly” now shows test ids
allow adding of attributes to test reports such that it also works with distributed testing (no upgrade of pytest-xdist needed)
- fix issue99 (in pytest and py) internallerrors with resultlog now produce better output - fixed by normalizing pytest_internalerror input arguments.
fix issue99 (in pytest and py) internallerrors with resultlog now produce better output - fixed by normalizing pytest_internalerror input arguments.
fix issue97 / traceback issues (in pytest and py) improve traceback output in conjunction with jinja2 and cython which hack tracebacks
fix issue93 (in pytest and pytest-xdist) avoid “delayed teardowns”: the final test in a test node will now run its teardown directly instead of waiting for the end of the session. Thanks Dave Hunt for the good reporting and feedback. The pytest_runtest_protocol as well as the pytest_runtest_teardown hooks now have “nextitem” available which will be None indicating the end of the test run.
fix collection crash due to unknown-source collected items, thanks to Ralf Schmitt (fixed by depending on a more recent pylib)
- fix issue90: introduce eager tearing down of test items so that teardown function are called earlier.
fix issue90: introduce eager tearing down of test items so that teardown function are called earlier.
add an all-powerful metafunc.parametrize function which allows to parametrize test function arguments in multiple steps and therefore from independent plugins and places.
add a @pytest.mark.parametrize helper which allows to easily call a test function with different argument values
Add examples to the “parametrize” example page, including a quick port of Test scenarios and the new parametrize function and decorator.
introduce registration for “pytest.mark.*” helpers via ini-files or through plugin hooks. Also introduce a “–strict” option which will treat unregistered markers as errors allowing to avoid typos and maintain a well described set of markers for your test suite. See examples at http://pytest.org/en/stable/how-to/mark.html and its links.
issue50: introduce “-m marker” option to select tests based on markers (this is a stricter and more predictable version of ‘-k’ in that “-m” only matches complete markers and has more obvious rules for and/or semantics.
new feature to help optimizing the speed of your tests: –durations=N option for displaying N slowest test calls and setup/teardown methods.
fix issue87: –pastebin now works with python3
fix issue89: –pdb with unexpected exceptions in doctest work more sensibly
fix and cleanup pytest’s own test suite to not leak FDs
fix issue83: link to generated funcarg list
fix issue74: pyarg module names are now checked against imp.find_module false positives
fix compatibility with twisted/trial-11.1.0 use cases
simplify Node.listchain
simplify junitxml output code by relying on py.xml
add support for skip properties on unittest classes and functions
- fix issue79: assertion rewriting failed on some comparisons in boolops
fix issue79: assertion rewriting failed on some comparisons in boolops
correctly handle zero length arguments (a la pytest ‘’)
fix issue67 / junitxml now contains correct test durations, thanks ronny
fix issue75 / skipping test failure on jython
fix issue77 / Allow assertrepr_compare hook to apply to a subset of tests
- fix assertion rewriting on files with windows newlines on some Python versions
fix assertion rewriting on files with windows newlines on some Python versions
refine test discovery by package/module name (–pyargs), thanks Florian Mayer
fix issue69 / assertion rewriting fixed on some boolean operations
fix issue68 / packages now work with assertion rewriting
fix issue66: use different assertion rewriting caches when the -O option is passed
don’t try assertion rewriting on Jython, use reinterp
- fix issue64 / pytest.set_trace now works within pytest_generate_tests hooks
fix issue64 / pytest.set_trace now works within pytest_generate_tests hooks
fix issue60 / fix error conditions involving the creation of pycache
fix issue63 / assertion rewriting on inserts involving strings containing ‘%’
fix assertion rewriting on calls with a ** arg
don’t cache rewritten modules if bytecode generation is disabled
fix assertion rewriting in read-only directories
fix issue59: provide system-out/err tags for junitxml output
fix issue61: assertion rewriting on boolean operations with 3 or more operands
you can now build a man page with “cd doc ; make man”
- fix issue53 call nosestyle setup functions with correct ordering
fix issue53 call nosestyle setup functions with correct ordering
fix issue58 and issue59: new assertion code fixes
merge Benjamin’s assertionrewrite branch: now assertions for test modules on python 2.6 and above are done by rewriting the AST and saving the pyc file before the test module is imported. see doc/assert.txt for more info.
fix issue43: improve doctests with better traceback reporting on unexpected exceptions
fix issue47: timing output in junitxml for test cases is now correct
fix issue48: typo in MarkInfo repr leading to exception
fix issue49: avoid confusing error when initialization partially fails
fix issue44: env/username expansion for junitxml file path
show releaselevel information in test runs for pypy
reworked doc pages for better navigation and PDF generation
report KeyboardInterrupt even if interrupted during session startup
fix issue 35 - provide PDF doc version and download link from index page
- fix issue38: nicer tracebacks on calls to hooks, particularly early configure/sessionstart ones
fix issue38: nicer tracebacks on calls to hooks, particularly early configure/sessionstart ones
fix missing skip reason/meta information in junitxml files, reported via http://lists.idyll.org/pipermail/testing-in-python/2011-March/003928.html
fix issue34: avoid collection failure with “test” prefixed classes deriving from object.
don’t require zlib (and other libs) for genscript plugin without –genscript actually being used.
speed up skips (by not doing a full traceback representation internally)
fix issue37: avoid invalid characters in junitxml’s output
- more precise (avoiding of) deprecation warnings for node.Class|Function accesses
tackle issue32 - speed up test runs of very quick test functions by reducing the relative overhead
fix issue30 - extended xfail/skipif handling and improved reporting. If you have a syntax error in your skip/xfail expressions you now get nice error reports.
Also you can now access module globals from xfail/skipif expressions so that this for example works now:
import pytest import mymodule @pytest . mark . skipif ( "mymodule.version[0] == " 1 ") def test_function (): pass
This will not run the test function if the module’s version string does not start with a “1”. Note that specifying a string instead of a boolean expressions allows py.test to report meaningful information when summarizing a test run as to what conditions lead to skipping (or xfail-ing) tests.
fix issue28 - setup_method and pytest_generate_tests work together The setup_method fixture method now gets called also for test function invocations generated from the pytest_generate_tests hook.
fix issue27 - collectonly and keyword-selection (-k) now work together Also, if you do “py.test –collectonly -q” you now get a flat list of test ids that you can use to paste to the py.test commandline in order to execute a particular test.
fix issue25 avoid reported problems with –pdb and python3.2/encodings output
fix issue23 - tmpdir argument now works on Python3.2 and WindowsXP Starting with Python3.2 os.symlink may be supported. By requiring a newer py lib version the py.path.local() implementation acknowledges this.
fixed typos in the docs (thanks Victor Garcia, Brianna Laugher) and particular thanks to Laura Creighton who also reviewed parts of the documentation.
fix slightly wrong output of verbose progress reporting for classes (thanks Amaury)
more precise (avoiding of) deprecation warnings for node.Class|Function accesses
avoid std unittest assertion helper code in tracebacks (thanks Ronny)
- refine and unify initial capturing so that it works nicely even if the logging module is used on an early-loaded conftest.py file or plugin.
refine and unify initial capturing so that it works nicely even if the logging module is used on an early-loaded conftest.py file or plugin.
allow to omit “()” in test ids to allow for uniform test ids as produced by Alfredo’s nice pytest.vim plugin.
fix issue12 - show plugin versions with “–version” and “–traceconfig” and also document how to add extra information to reporting test header
fix issue17 (import-* reporting issue on python3) by requiring py>1.4.0 (1.4.1 is going to include it)
fix issue10 (numpy arrays truth checking) by refining assertion interpretation in py lib
fix issue15: make nose compatibility tests compatible with python3 (now that nose-1.0 supports python3)
remove somewhat surprising “same-conftest” detection because it ignores conftest.py when they appear in several subdirs.
improve assertions (“not in”), thanks Floris Bruynooghe
improve behaviour/warnings when running on top of “python -OO” (assertions and docstrings are turned off, leading to potential false positives)
introduce a pytest_cmdline_processargs(args) hook to allow dynamic computation of command line arguments. This fixes a regression because py.test prior to 2.0 allowed to set command line options from conftest.py files which so far pytest-2.0 only allowed from ini-files now.
fix issue7: assert failures in doctest modules. unexpected failures in doctests will not generally show nicer, i.e. within the doctest failing context.
fix issue9: setup/teardown functions for an xfail-marked test will report as xfail if they fail but report as normally passing (not xpassing) if they succeed. This only is true for “direct” setup/teardown invocations because teardown_class/ teardown_module cannot closely relate to a single test.
fix issue14: no logging errors at process exit
refinements to “collecting” output on non-ttys
refine internal plugin registration and –traceconfig output
introduce a mechanism to prevent/unregister plugins from the command line, see http://pytest.org/en/stable/how-to/plugins.html#cmdunregister
activate resultlog plugin by default
fix regression wrt yielded tests which due to the collection-before-running semantics were not setup as with pytest 1.3.4. Note, however, that the recommended and much cleaner way to do test parameterization remains the “pytest_generate_tests” mechanism, see the docs.
- pytest-2.0 is now its own package and depends on pylib-2.0
pytest-2.0 is now its own package and depends on pylib-2.0
new ability: python -m pytest / python -m pytest.main ability
new python invocation: pytest.main(args, plugins) to load some custom plugins early.
try harder to run unittest test suites in a more compatible manner by deferring setup/teardown semantics to the unittest package. also work harder to run twisted/trial and Django tests which should now basically work by default.
introduce a new way to set config options via ini-style files, by default setup.cfg and tox.ini files are searched. The old ways (certain environment variables, dynamic conftest.py reading is removed).
add a new “-q” option which decreases verbosity and prints a more nose/unittest-style “dot” output.
fix issue135 - marks now work with unittest test cases as well
fix issue126 - introduce py.test.set_trace() to trace execution via PDB during the running of tests even if capturing is ongoing.
fix issue123 - new “python -m py.test” invocation for py.test (requires Python 2.5 or above)
fix issue124 - make reporting more resilient against tests opening files on filedescriptor 1 (stdout).
fix issue109 - sibling conftest.py files will not be loaded. (and Directory collectors cannot be customized anymore from a Directory’s conftest.py - this needs to happen at least one level up).
introduce (customizable) assertion failure representations and enhance output on assertion failures for comparisons and other cases (Floris Bruynooghe)
nose-plugin: pass through type-signature failures in setup/teardown functions instead of not calling them (Ed Singleton)
remove py.test.collect.Directory (follows from a major refactoring and simplification of the collection process)
majorly reduce py.test core code, shift function/python testing to own plugin
fix issue88 (finding custom test nodes from command line arg)
refine ‘tmpdir’ creation, will now create basenames better associated with test names (thanks Ronny)
“xpass” (unexpected pass) tests don’t cause exitcode!=0
fix issue131 / issue60 - importing doctests in init files used as namespace packages
fix issue93 stdout/stderr is captured while importing conftest.py
fix bug: unittest collected functions now also can have “pytestmark” applied at class/module level
add ability to use “class” level for cached_setup helper
fix strangeness: mark.* objects are now immutable, create new instances
Your coding agent can read these notes before it upgrades. Set up the MCP server →