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
Built Distribution
File details
Details for the file postfix-0.0.2.tar.gz
.
File metadata
- Download URL: postfix-0.0.2.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | a403127414e37c723d639d2d3193d040df848b2b3db06004348a4030cc012513 |
|
MD5 | b7240e13c2c3dcc338ec2d999a4eca88 |
|
BLAKE2b-256 | f28bf0ef302547dd85665835009eb539d33b10dd97c9eabb4513b8cf3a389779 |
File details
Details for the file postfix-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: postfix-0.0.2-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e66f5c51334b467e2edd58734f01a0fcb50659b3ecf4f7660f6c878c1a5ecce |
|
MD5 | 8027fb152dd8ded3691572e352d40447 |
|
BLAKE2b-256 | fae0ce7ea1e471bcc65316f52eb654e098b658e24d1b5183bdee61a7e5a52102 |