The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
Python
Latest commit d15724f Jan 18, 2017 @RonnyPfannschmidt RonnyPfannschmidt committed on GitHub Merge pull request #2204 from nicoddemus/linux-marker-doc
Fix marker example on "linux" platform
Permalink
Failed to load latest commit information.
.github Mention small doc fixes don't need tests/changelog entries in PR temp… Oct 5, 2016
_pytest Refactor plugin specs handling into an isolated function Jan 12, 2017
bench simplify internal pytester machinery Oct 6, 2014
doc/en Fix marker example on "linux" platform Jan 17, 2017
extra Adapt get_issues.py script for GitHub (instead of Bitbucket) Mar 28, 2016
scripts Only execute "coveralls" toxenv on master once Nov 24, 2016
testing Refactor plugin specs handling into an isolated function Jan 12, 2017
.coveragerc Ignore vendored_packages folder for coverage purposes Sep 14, 2015
.gitattributes Use "union" merge strategy for CHANGELOG Aug 10, 2015
.gitignore merge master to features Jun 1, 2016
.travis.yml Merge pull request #2136 from hroncok/i2132 Dec 28, 2016
AUTHORS Switch monkeypatch fixture to yield syntax Jan 4, 2017
CHANGELOG.rst Consider plugins loaded by PYTEST_PLUGINS for assertion rewrite Jan 11, 2017
CONTRIBUTING.rst Add documentation building note. Nov 26, 2016
HOWTORELEASE.rst Send only minor/major release announces to TIP mailing list Sep 2, 2016
LICENSE Wrap lines at 79 characters Feb 16, 2016
MANIFEST.in Only install pypy on AppVeyor for "pypy" tox-env Nov 12, 2016
README.rst Use "inc" instead of "func" in the snipped on README and doc index Nov 27, 2016
appveyor.yml Add py36 to test on AppVeyor Jan 5, 2017
pytest.py revert setuptools_scm addition introduced with f22d14b Sep 17, 2015
setup.cfg Ensure the LICENSE is included in built wheels Jan 10, 2017
setup.py Explicitly add setuptools to install_requires Dec 19, 2016
tox.ini Test Python 3.6 on Travis CI Dec 27, 2016

README.rst

pytest
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;
  • Python2.6+, Python3.3+, PyPy-2.3, Jython-2.5 (untested);
  • Rich plugin architecture, with over 150+ external plugins and thriving community;

Documentation

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

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-2016.

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