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
Release history Release notifications | RSS feed
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 pytest_common_subject-1.1.1.tar.gz
.
File metadata
- Download URL: pytest_common_subject-1.1.1.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/5.13.0-52-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edc22c82c2952972e212a9a1be3bd79649c11461b81b7d42408744b34a097d89 |
|
MD5 | fd426e86e71e276dfbd05c92ec6e85e1 |
|
BLAKE2b-256 | dd50c50f81e1c3f26ce6ad194b34d3ce2d805fe137157f60390a8037f6d3cce5 |
File details
Details for the file pytest_common_subject-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: pytest_common_subject-1.1.1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/5.13.0-52-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d6372cf887490c879e7889166e728ecb8f9189b3bc218a8698a9d09adf4fa17 |
|
MD5 | 17b651a8a4729838e7c2d5d0ad902634 |
|
BLAKE2b-256 | 7cd17762b9f15f24027a99d88856d465e339c25d86c5035c9db1def3d0bbb3b5 |