internalsGet Pro

Module 03 · Lesson 8 of 10Pro

Testing data code with pytest

Level
Intermediate
Topic
Python for data engineering
Reading time
17 min

When you finish this page you can

  1. Write pytest tests for pipeline functions, with small hand-written inputs that each cover one case.
  2. Use fixtures for each test’s setup and teardown, and parametrize to run one test over many cases.
  3. Decide what a test should talk to, whether a real in-memory DuckDB, a fake or a real PostgreSQL.
  4. Turn every fixed bug into a regression test, so the next change can’t bring it back.
  1. SQL style, reviews and tests for pipelines16 min
  2. Reading and writing CSV, JSON and Parquet in Python14 min
  3. Reading and writing databases from Python16 min

Thursday’s fix undid Tuesday’s

is an online store in India. Every night a cron job loads the day’s orders and click events into , between 01:00 and about 03:30. At 05:00 the courier partner drops a CSV of the day’s deliveries, and a Python step matches it to Kartly’s shipments. Daniel, who leads finance reporting, reads the result at 07:00.

Our biggest sale ever · Black Friday

Flat 50% Off

Pro

Continue reading

Unlock every course, now and later

  • System Design, live
  • AI Engineering, live
  • Data Engineering, live
  • Machine Learning Engineering, live
  • Inference Engineering, coming soon
  • AI Research, coming soon
  • Performance Engineering, coming soon
  • Agent & Harness Engineering, coming soon
  • LLM Fine-tuning, coming soon
  • LLM Pre-training & Post-training, coming soon
  • Reinforcement Learning, coming soon
  • AI Infrastructure & Platform Engineering, coming soon
  • AI Evaluation & Safety, coming soon
  • Forward Deployed Engineering, coming soon
  • Cloud Computing, coming soon
  • DevOps, coming soon

50% off · Annual and Lifetime

BLACKFRIDAY50Applied at checkout

Choose a plan