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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: postfix-0.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 e8792cc3c0d2d978b266834f12532d94aa2d6c347d3f4fdd7efdb7e709889787
MD5 0290c3f4104ffeba4ed8ab534df72263
BLAKE2b-256 841c7341a408fe1e355d99ca2ac92b8b585019fc68c194c99ce3e06a5633fb30

See more details on using hashes here.

File details

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

File metadata

  • Download URL: postfix-0.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e1eedf54302bcc68883017655d8022a319b00f3a4f2ee1dab2810fe9522437e9
MD5 e9d687eb457f975393089b9a054c1d3c
BLAKE2b-256 d8af580c08b21f9eb9eb2b36db3da88160b1e380db42151c34cbdb1ab4b56803

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