The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
Latest commit 4b164d9 Oct 10, 2018
Permalink
Failed to load latest commit information.
.github Manage GH labels using the new 'labels' tool Jul 14, 2018
bench Upgrade pre-commit hooks Oct 8, 2018
changelog Merge pull request #4076 from nicoddemus/unittest-param-fixture-msg Oct 6, 2018
doc/en Fix formatting for plugin loading in conftest Oct 9, 2018
extra sort out flake8 issues and unicode name usage May 23, 2018
scripts coverage: use modules for source Sep 19, 2018
src re-enable linting tox env on windows Oct 9, 2018
testing Merge pull request #4089 from asottile/upgrade_hooks Oct 9, 2018
.coveragerc coverage: use modules for source Sep 19, 2018
.gitattributes Add codecov support to AppVeyor and remove coveralls Sep 5, 2018
.gitignore Ignore Sphinx's .doctrees folder Sep 14, 2018
.pre-commit-config.yaml re-enable linting tox env on windows Oct 9, 2018
.travis.yml coverage: use modules for source Sep 19, 2018
AUTHORS Ensure user_properties is a list Sep 26, 2018
CHANGELOG.rst Preparing release version 3.8.2 Oct 2, 2018
CITATION Fix linting issues Jul 14, 2018
CONTRIBUTING.rst Improve contributing instructions regarding black/linting Jun 11, 2018
HOWTORELEASE.rst Update release procedure [ci skip] Aug 29, 2018
LICENSE Update copyright date in LICENSE and README.rst Jun 13, 2017
README.rst Replace coveralls' badge by codecov's Sep 6, 2018
appveyor.yml Revert "Merge pull request #4094 from pytest-dev/asottile/asottile-pa… Oct 9, 2018
pyproject.toml Use "pytest" on the CHANGELOG Jul 27, 2018
setup.cfg restore setuptools_scm write_to usage Apr 23, 2017
setup.py Move code to get width of current line to a function Aug 31, 2018
tox.ini tox: coverage factor: combine and report Sep 17, 2018

README.rst

pytest
Code coverage Status https://travis-ci.org/pytest-dev/pytest.svg?branch=master https://ci.appveyor.com/api/projects/status/mrgbjaua7t33pg6b?svg=true

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.

License

Copyright Holger Krekel and others, 2004-2018.

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