The Pytest Cookbook - recipes with videos and repos¶
Motivation¶
I really enjoy coming a across a resource that helps me understand a subject and that has a repo of the code that works 'out of the box' and additionally a video explainer rather than just an article.
I have created or collected such resources and combined them into a 'book', citing references where appropriate.
Purpose of this book¶
-
To provide a number of ready built and congfigurable FULL STACK PYTHON TEST FRAMEWORK, (PFS), comprising of over 200 highly commented test templates for developers to adapt to their own needs along with resource links that have helped me greatly, as well as integration of these into the frameworks.
-
To provide a curated source of articles and videos that surround PyTest, for example Docker, that enable 'out of the box' ease of use. Some are created by me, others reference with acknowledgments other sources.
PyTest Full Stack, (PFS)¶
The PyTest Full Stack suite has an installation that will just require a 1-2-3 of:
pip install -r requirements.txt
.playwright install
to load Playwright browsers.python -m pytest -v
to run over 200 tests.
PFS uses a number of PyTest hooks for utilities and features.
One of these is customising the terminal report and one can configure the output in a number of ways, explained in articles and videos.
Here is a sample output:
Custom header sections¶
Customised words, colours and icons¶
Custom footer sections¶
The frameworks have logging and other utilities installed to provide a complete framework.
Resources included are:
- Links to helpful articles, videos and documentation.
- Converted and transcribed code of great YT videos where there is no code repo.
Test frameworks¶
See the README.md in root of each test framework for detailed and up to date set up instructions.
There are two main test frameworks:
- PyTest Full Stack - a full stack testing framework from SQL Schemas to E2E testing with Playwright
- PyTest Django Full Stack- is its own unique testing framework built from a range of sources. (Under construction and will be a PyTest-Full-Stack test suite for Django).
I strive to acknowledge sources I have used to learn PyTest and any adaptations of code samples used therein.
As a curated list of resources, I have integrity over linking to the work of others and due credits are given.
Often I am a wrapper around someone else's effort and I try to add a different presentation whre possible, as we often find our understanding with a different presentation of the subject. Hence having may teachers enables us all as eternal students to get our heads around sometimes very complex subjects.