Skip to main content

pytest framework for testing different aspects of a common method

Project description

pytest-common-subject

pytest-common-subject PyPI version pytest-common-subject PyPI pyversions pytest-common-subject PyPI license

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.

Source Distribution

pytest-common-subject-1.0.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

pytest_common_subject-1.0.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest-common-subject-1.0.1.tar.gz.

File metadata

  • Download URL: pytest-common-subject-1.0.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.12 CPython/3.6.7 Linux/4.18.0-20-generic

File hashes

Hashes for pytest-common-subject-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1e94ab317cb3180f9cd1b18b533a1b88dc3be9e186f53e1de83f0389300310ae
MD5 4e29c5e15c37f0073c077d1a3f88cba0
BLAKE2b-256 490f7d2eb57950c661bd630cd1b87a4c79a866b111933a2fe692331da2e95e68

See more details on using hashes here.

File details

Details for the file pytest_common_subject-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_common_subject-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c305627e822e93572df80cb5605255358eddece0a9d4d21b8aeebc8c0311370
MD5 f2f4579646e9dea6b0ccedeeb9b8cab9
BLAKE2b-256 6a5c3f328b2b9e77e48b480612c670d3cafa633cd70a93213a4bdaf06159c9a6

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