Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

py.test plugin for regression tests

Project description

This pytest-plugin allows capturing of output of test functions which can be compared to the captured output from former runs. This is a common technique to start TDD if you have to refactor legacy code which ships without tests.

To install and activate this plugin you have to run:

$ pip install pytest-regtest

from your command line.

This py.test plugin provides a fixture named regtest for recording data by writing to this fixture, which behaves like an output stream:

def test_squares_up_to_ten(regtest):

    result = [i*i for i in range(10)]

    # one way to record output:
    print >> regtest, result

    # alternative method to record output:
    regtest.write("done")

For recording the approved output, you run py.test with the –reset-regtest flag:

$ py.test --reset-regtest

The recorded output is written to text files in the subfolder _regtest_outputs next to your test scripts.

You can reset recorded output of files and functions individually as:

$ py.test --reset-regtest tests/test_00.py
$ py.test --reset-regtest tests/test_00.py::test_squares_up_to_ten

If you want to check that the testing function still produces the same output, you ommit the flag and run you tests as usual:

$ py.test

This shows diffs for the tests failing because the current and recorded output deviate.

Project details


Release history Release notifications

History Node

1.2.0

History Node

1.0.15

History Node

1.0.14

History Node

1.0.13

History Node

1.0.12

History Node

1.0.11

History Node

1.0.10

History Node

1.0.9

History Node

1.0.8

History Node

1.0.7

History Node

1.0.6

History Node

1.0.5

History Node

1.0.4

History Node

1.0.3

History Node

1.0.2

History Node

0.15.1

History Node

0.15.0

History Node

0.14.2

History Node

0.14.1

History Node

0.14.0

History Node

0.13.1

History Node

0.13.0

History Node

0.12.2

History Node

0.12.1

History Node

0.12.0

History Node

0.11.1

History Node

0.11.0

History Node

0.10.0

History Node

0.9.3

History Node

0.9.2

History Node

0.9.1

History Node

0.9.0

History Node

0.8.3

History Node

0.8.2

History Node

0.8.1

History Node

0.8.0

History Node

0.7.0

History Node

0.6.1

History Node

0.6.0

History Node

0.5.1

History Node

0.5.0

History Node

0.4.1

History Node

0.4.0

History Node

0.3.0

This version
History Node

0.2.2

History Node

0.2.1

History Node

0.2.0

History Node

0.1.0

History Node

0.0.5

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pytest-regtest-0.2.2.tar.gz (3.1 kB) Copy SHA256 hash SHA256 Source None Sep 24, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page