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

Uploaded Source

Built Distribution

pytest_common_subject-1.0.6-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest-common-subject-1.0.6.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.4 Linux/5.13.0-40-generic

File hashes

Hashes for pytest-common-subject-1.0.6.tar.gz
Algorithm Hash digest
SHA256 e3cd860c7e6e4481f29a47f80b41a0c186d146f529a2f346b8a9f3ed4e113f6c
MD5 d07c2feb846e5856eba17d3ccfcf2bd8
BLAKE2b-256 bd31a3b99affc430e3c4be0720a8b18ca136147b7fe6effed90015384d98f14e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_common_subject-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3717bb80359513dd679744805fc39bf34ed48c872be9cbe616c69291bff54f1c
MD5 eb1689e4c13fe28fd5210e4a3cdf8bc0
BLAKE2b-256 073b1aa631074838c1198819b81f62801c20dc09f230058d394ce573670629a6

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