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.5.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

postfix-0.0.5-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: postfix-0.0.5.tar.gz
  • Upload date:
  • Size: 4.4 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.5.tar.gz
Algorithm Hash digest
SHA256 a97beb346f27b37a11f6f997a9f4bf22720cf93b0394653210b812a34a211534
MD5 00247dd72097e7075c1693bf21e76d9d
BLAKE2b-256 bd3a1735a41e7252ceb00f78d2f0a63179f4a4f5c68de821844e680cd3c36871

See more details on using hashes here.

File details

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

File metadata

  • Download URL: postfix-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.1 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a957a455e751fcb0480c8915a2bf6dcafd032e005dfc950d28b49e1a35da88ac
MD5 c9cdbc9c416f1ea6879a305ec619f26f
BLAKE2b-256 273818c4105772f2434362113f76a253adf231b0ce616512600d7e9a692d0fa3

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