pytest framework for testing different aspects of a common method
Project description
pytest-common-subject
pytest-common-subject is a "framework" for organizing tests to reduce boilerplate while writing, improve skimmability when reading, and bolster parallelization when executing the suite.
To utilize this framework, we first choose a single function that our group of tests will all call — in other words, an entry point, or a common subject. This function will be automatically called before each of our tests, with args and kwargs that can be customized by overriding fixtures — enabling child test classes to make HTTP requests as a different user, or to use a different cache backend, or to change the value of a monkeypatched method.
The return value of the chosen function will be passed as a fixture to each test. To reap the full benefits of the framework, create separate tests to verify different aspects of the return value. Was the response status code a 200? Did the response contain the expected data? Were the expected rows created in the database? By using separate tests for each of these aspects, we can pinpoint and correct multiple bugs at once, instead of getting sucked into a fix-test-fix cycle with its chorus of "oh, bother, not again!"
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size pytest_common_subject-1.0.5-py3-none-any.whl (7.8 kB) | File type Wheel | Python version py3 | Upload date | Hashes View |
Filename, size pytest-common-subject-1.0.5.tar.gz (8.9 kB) | File type Source | Python version None | Upload date | Hashes View |
Hashes for pytest_common_subject-1.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afb7eccf7f7f836890be0f517fa4731142577f01058c003b6b63cf322a4eb7ec |
|
MD5 | 61fdb35cc2b5411dce0d902c84edc5b2 |
|
BLAKE2-256 | a9b0fe148d546ce9e73631a79fd0a9d112163a1041d5d8dd22ccfb7c1ffc664a |
Hashes for pytest-common-subject-1.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | acfa86af84c122bb4cda538ca76c78d11d8da68dfd25a3831e756a525d0ca13c |
|
MD5 | 7387c43d7a91c96cc579709fbf7cd084 |
|
BLAKE2-256 | 249662666e7b9b3517055bf6d11f6e4ecf2ac50fa63e1b8275677afae00cb349 |