Skip to content

Welcome

Go to:    pytest-cookbook.com

Then:    PyCon IRE 2024 -> Welcome

https://docs.pytest.org/en/stable/contents.html

git clone https://github.com/Python-Test-Engineer/PyTest-Full-Stack to save time

Then goto FINAL PROJECT for instructions

Let's get comfortable and confident with PyTest.

Welcome to the Getting Started with PyTest workshop.

There are a lot of resources both for the workshop and after so that you can feel comfortable and confident with PyTest.

There are a lot of features to PyTest but 20% of them will cover 80% of your needs, so I will highlight the essentials, the rest you just need to be aware of rather than fully grasp now.

Today, it is more important to grasp the wiring of PyTest rather than exact syntax.

To know what is possible for future use.

When you return to PyTest when you are back at work, a solid understanding will serve you best. One can always look up syntax.

Who am I?

I am one of US - a regular Pythonista.

I am an 'adhoc' freelance Backend Pythonista and Test Automation Engineer living in Brighton, UK.

Currently, I am also working on a project 'AI Powered Knowledge Systems', building a book/framework similiar to PFS.

brighton

Volounteer coach

I am a volounteer coach at codebar.io/brighton

codebar

and I also enjoy working in community kitchens, dogs and partner dancing.

Leo!

Just got a Red Fox Labrador Pup Leo, (much earlier than planned):

Leo

We have a local red fox that is apt to follow us...

Leo

My first computer 1979

tape https://en.wikipedia.org/wiki/Punched_tape#/media/File:Creed_model_6S-2_paper_tape_reader.jpg

...cut and paste was cut and paste!

Motivation

There are many great resources for PyTest and I wanted to curate them into one resource, but without creating unuseable bulk.

In my experience, I look for 3 things:

  1. Good docs.
  2. A repo that works out of the box.
  3. Videos to explain concepts.

I hope PyTest FullStack, (PFS), achieves this. It is a Full Stack PyTest framework from SQL DB tests to E2E tests with Playwright.

We will work in a circular way, going back to concepts we have seen before. This helps learning, so don't be too concerned if things don't click at first.

Agenda

There are two ways we can create a PyTest Framework for our src code:

  1. Use a template framework and add in our src.

  2. Integrate a template framework around our src.

We will do both.

We will split the workshop into four main sections:

1. PFS framework

Having seen a demo of a minimal installation of PyTest, we will get familiar with all the resources available and download Python Full Stack which is a complete framework for PyTest with over 200 template tests from SQL to API/E2E testing with Playwright.

Learn how to create this framework from scratch and we will learn how to use it and run/select tests.

Please note you can just install PyTest and add a tests folder to your project and this will work fine.

2. PyTest 101

This is the core of PyTesting, creating, selecting, running and outputs:

  • Create functional and class based test templates.
  • Test discovery customisation.
  • Running tests.
  • Selecting tests with -k (like) and markers.
  • Using built in markers to skip tests etc.

3. PyTest 102

We will look at PyTest features to make testing easier. They are not necessary for PyTesting but are powerful features to save time and code:

  • Fixtures
  • Parametrization
  • Conftest.py
  • Plugins for HTML Reports, Coverage and performance, (pytest-xdist).

4. Afterwards

We will look at a great many resources available afterwards to help refresh and deepen your understanding. These range from videos, some made by me and the rest by the community, as well articles and other materials.

There are two video series that I used in my original learning that are concise and effective. They are referenced in https://pytest-cookbook.com/learn/ and we will look at them later.

My intention is for you to feel comfortable and confident with PyTest, ready to use and deepen your skill set from today.

There is a coupon for my Udemy course 'Pytest Hooks and Plugins'. I will give link later and it is accessible until end of Monday.

Timings

I am mindful that the talks etc after 11 am break start at 11:20, the time the workshop is due to end.

I propose we aim to end the formal workshop at 11 am so that people can if they want get a coffee and go the next talk/workshop.

I will use the last 20 minutes from 11-11:20 for supplementary questions/revision etc for those that want it.

We can go over some intermediate/advanced concepts too.