Skip to main content

A Python package to facilitate writing tests for a testless code base.

Project description

postfix

A Python package to facilitate writing tests for a testless code base.

Installation

pip install --upgrade postfix

Usage

Suppose you have some tremendously complex code, but no tests for that code. But you are sufficiently convinced, that right now, it's working as it should. You want to do some refactoring, but you don't dare to do so without tests (wise decision!). So you decide to write tests a posteriori to make sure that after refactoring, the code works as before. Let's suppose that we want to create tests for the function myfunc and the method MyClass.mymethod (see example/state_1). And let's suppose that it is complicated to get realistic data for the arguments of that function/method. In order to quickly get a first test coverage with realistic input and output data, we will use postfix to create test fixtures. Annotate the function or method for which you create a fixture with the decorator postfix.create_fixture (see example/state2) and run your code. Remove the decorators from the production code, move the dumped fixture files to your newly created test suite directory and use them to write tests (see examples/state_3).

Limitations

In postfix you cannot instrument methods or functions that are located in the main module. However, for any nontrivial project with more than one Python file this should not be a limitation.

Project details


Download files

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

Source Distribution

postfix-0.0.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

postfix-0.0.3-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file postfix-0.0.3.tar.gz.

File metadata

  • Download URL: postfix-0.0.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.2

File hashes

Hashes for postfix-0.0.3.tar.gz
Algorithm Hash digest
SHA256 8f1b6ea2816b76c8c05d628cda18554ab819ed9c19c7cc4332244bd0e22a8539
MD5 2503cf0e9104ec2a1d366de3f9321564
BLAKE2b-256 cfa98c36cc9a14621dc1bf9975467bd37a13f54a360ab395cfd8258579246e11

See more details on using hashes here.

File details

Details for the file postfix-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: postfix-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.2

File hashes

Hashes for postfix-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1681cd46592304de7b2d198ada74bd4bd57c7bf2b64714b63847e96aa5a7464c
MD5 4bee7834906bf0f0902c1e5974917203
BLAKE2b-256 283e8a79fbf2d0fe65d5a7ed071003fe2943ed1e55518e20ce6b279da9a50cba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page