The Pytest Cookbook - recipes with videos and repos¶
Purpose of this book¶
To provide a number of ready built and congfigurable FULL STACK PYTHON TEST FRAMEWORK, comprising of over 180 test templates and references for developers to adapt to their own needs.
Links to resources I have found very helpful, as well as integration of these into the frameworks, are included.
Installation will require just a 1-2-3 of:
- 'python -m venv venv` to create virtual environment.
pip install -r requirements.txt
.playwright install
to load Playwright browsers.
We use a number of hooks for utilities and featues.
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:
Custome 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.
Test frameworks¶
See the README.md in root of each Test framework for detailed and up to date set up instructions.
These two main test frameworks:
- PyTest_01_Full - a full stack testing framework from SQL Schemas to E2E testing with Playwright
- PyTest_02_DJANGO - is its own unique testing framework built from a range of sources. (Under construction and will be a 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 each 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.
About me¶
I am a Python Test Engineer using PyTest and Playwright as well as a Software Tester.
I enjoy building Plugins and I hae created a PyTest Hooks and Plugin online video course that teaches how to create lite versions of some well known plugins as well as our own useful custom plugins which can be made distributabe:
Example plugins are:
- CSV Lite Reporter
- Export results to DB
- Sorting, randomizing and deselecting tests
- Customising the console report
The course is available Udemy Hooks and Plugins course and Udemy has a sale ever two weeks and the cost would be $20 USD approx.
There is more information about me and my services here.
How best to use this book¶
For PyTest-Full-Stack framework:
Download or git clone from repo.
For prettier general console output, Rich and PyBoxen, built on Rich, are used.
PyTest-sugar, an excellent plugin, was used but with the inclusion of the pytest_terminal_summary hook in the conftest.py file of PyTest-Full-Stack, we have rich console output that is configurable and customisable.
YouTube Videos¶
I have made some videos to assist in using this book.
These are available here.