Skip to content
The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
Branch: master
Clone or download
blueyed Merge pull request #5262 from asottile/mode_non_binary
Remove 'b' from sys.stdout.mode
Latest commit c8f7e50 May 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github GitHub: revisit issue/PR templates [ci skip] Apr 23, 2019
bench Use exec directly May 7, 2019
changelog Merge pull request #5262 from asottile/mode_non_binary May 15, 2019
doc/en Fix indentation and use code-block directives May 14, 2019
extra Fix formatting of print() calls Nov 22, 2018
scripts ci: Azure: fix coverage generation with PyPy Mar 4, 2019
src Remove 'b' from sys.stdout.mode May 14, 2019
testing Remove 'b' from sys.stdout.mode May 14, 2019
.coveragerc .coveragerc: use "src" only from current dir Mar 22, 2019
.gitattributes Add codecov support to AppVeyor and remove coveralls Sep 5, 2018
.gitignore Ignore pip-generated 'pip-wheel-metadata' folder [skip ci] Feb 8, 2019
.pre-commit-config.yaml Add Tidelift management docs and blurb on README, as discussed in the ML May 9, 2019
.travis.yml Upgrade PyPy to 7.1.1 May 4, 2019
AUTHORS add @EvanKepner to authors May 12, 2019
CHANGELOG.rst Preparing release version 4.5.0 May 11, 2019
CITATION Fix linting issues Jul 14, 2018
CONTRIBUTING.rst Update Black URLs May 4, 2019
HOWTORELEASE.rst doc: fix HOWTORELEASE.rst Nov 3, 2018
LICENSE Update copyright year Jan 4, 2019
README.rst Add Tidelift management docs and blurb on README, as discussed in the ML May 9, 2019
TIDELIFT.rst Add Tidelift management docs and blurb on README, as discussed in the ML May 9, 2019
azure-pipelines.yml Use 'pypy' as executable on PyPy env [skip travis] May 4, 2019
pyproject.toml Use isolated_build option in tox.ini Feb 8, 2019
setup.cfg Fix usages of py.io.saferepr Jan 21, 2019
setup.py Merge remote-tracking branch 'upstream/master' into merge-master-into… May 9, 2019
tox.ini ci: tox: fix py37-freeze May 14, 2019

README.rst

pytest
Code coverage Status https://travis-ci.org/pytest-dev/pytest.svg?branch=master https://dev.azure.com/pytest-dev/pytest/_apis/build/status/pytest-CI?branchName=master

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries.

An example of a simple test:

# content of test_sample.py
def inc(x):
    return x + 1


def test_answer():
    assert inc(3) == 5

To execute it:

$ pytest
============================= test session starts =============================
collected 1 items

test_sample.py F

================================== FAILURES ===================================
_________________________________ test_answer _________________________________

    def test_answer():
>       assert inc(3) == 5
E       assert 4 == 5
E        +  where 4 = inc(3)

test_sample.py:5: AssertionError
========================== 1 failed in 0.04 seconds ===========================

Due to pytest's detailed assertion introspection, only plain assert statements are used. See getting-started for more examples.

Features

  • Detailed info on failing assert statements (no need to remember self.assert* names);
  • Auto-discovery of test modules and functions;
  • Modular fixtures for managing small or parametrized long-lived test resources;
  • Can run unittest (or trial), nose test suites out of the box;
  • Python 2.7, Python 3.4+, PyPy 2.3, Jython 2.5 (untested);
  • Rich plugin architecture, with over 315+ external plugins and thriving community;

Documentation

For full documentation, including installation, tutorials and PDF documents, please see https://docs.pytest.org/en/latest/.

Bugs/Requests

Please use the GitHub issue tracker to submit bugs or request features.

Changelog

Consult the Changelog page for fixes and enhancements of each version.

Support pytest

You can support pytest by obtaining a Tideflift subscription.

Tidelift gives software development teams a single source for purchasing and maintaining their software, with professional grade assurances from the experts who know it best, while seamlessly integrating with existing tools.

Security

pytest has never been associated with a security vunerability, but in any case, to report a security vulnerability please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

License

Copyright Holger Krekel and others, 2004-2019.

Distributed under the terms of the MIT license, pytest is free and open source software.

You can’t perform that action at this time.