Module 0 ยท Python for SDETs

Set Up Your
Python Test Stack

From an empty folder to a green test against a real app

Python venv pytest requests
AI with Rufat
What you'll install

Four tools, one toolchain

๐Ÿ

Python 3.9+

The language your tests are written in.

๐Ÿ“ฆ

venv

An isolated, per-project package folder โ€” no version clashes.

โœ…

pytest

The test runner that's the de-facto SDET standard.

๐ŸŒ

requests

The library you'll use to call the app's REST API.

AI with Rufat
The path to green

Setup, end to end

YOUR TEST PROJECT
Install Python
โ†’
python -m venv .venv
โ†’
activate
โ†’
pip install pytest requests
THE PRACTICE APP, THEN PROOF
git clone
โ†’
npm install && npm start
โ†’
write test_smoke.py
โ†’
โœ“ 1 passed
AI with Rufat
Two terminals, two jobs
๐Ÿ–ฅ๏ธ Terminal 1 โ€” the app
testmarket-lab
$ npm start
TestMarket Lab running
โ†’ http://localhost:3000
(leave this running)
๐Ÿงช Terminal 2 โ€” your tests
python-sdet
(.venv) active
$ pytest
1 passed in 0.05s
(run as often as you like)
AI with Rufat
One test proves the whole stack
tests/test_smoke.py
import requests
def test_products_endpoint_is_up():
r = requests.get("http://localhost:3000/api/products")
assert r.status_code == 200
products = r.json()
assert isinstance(products, list)
assert len(products) > 0
pytest
python-sdet
collected 1 item
tests/test_smoke.py . [100%]
1 passed in 0.05s
Green = Python + venv + pytest + requests + the app all wired up.
AI with Rufat
๐ŸŽ‰

You're
Set Up

A real local stack โ€” and a real app answering on :3000

โžก๏ธ
Module 1
pytest itself โ€” discovery, assert, running exactly what you want
โ™ป๏ธ
Reset anytime
POST /api/reset returns the data to a known state
๐Ÿ–ฅ๏ธ
Keep it running
The app stays up in its own terminal while you test
AI with Rufat
โ† / โ†’ ยท space