Agenda: Python (2026-11-11 - 2026-11-13)#
Labgrid/pytest Course Project?#
A homogenous team does not want to walk through endless stupid exercises, so lets try to define a (semi) realistic project that we can use to get our fingers dirty, and add dynamicity to the course.
For example (this is what I was able to bring home from our meeting on 2026-10-21),
Export test cases from Jira/Zephyr (https://www.youtube.com/watch?v=p0WXAHC4cIo)
Parse exported, convert to (interpret with?)
pytestFixtures: acquiring resources in Labgrid
Labgrid “strategy”? (Labgrid Tutorial #4 - Write Your Own Strategy)
Day 1#
Basics#
This is everything that’s in Python: The Language Fundamentals. Chances are that boring basics will be covered quickly and we can move on to more interesting topics. Nonetheless we don’t let anyone get through without knowing what (im)mutability is, for example, or what a variable is, and where the types are.
File I/O (CSV And JSON), pytest, Virtual Environments#
pytest Introduction, By Example (mention The unittest Module, only to say
pytestis much better)
Day 2#
Object Oriented Programming, Exception Handling#
Covering the basics of OO. This is what people need most, if only to structure code readably.
From Object Oriented Programming:
Note
More OO Topics
There’s more in Object Oriented Programming. Lets ignore this for a while, and watch out for opportunities to cover it too.
Modules And Packages#
Not knowing better, we have put all code in one flat directory. Tests, code/classes, and commandline programs. Restructure the mess, talking about project structure, making recommendations.
Logging#
Introduce logging into our growing application, covering parse errors, network errors, and all such external nastities.
Note
TODO Create material about the Python logging package
Decorators (The @ In A Fixture)#
Answering the question “What’s the @ when I write a pytest
fixture?”, lets go over something surprisingly simple.
Generators (“Yield” Fixtures)#
In pytest, one can comfortably cut a fixture “function” in two
halves - the setup and the teardown part - by calling yield in the
middle. Technically, the “function” has become a generator. There
are more uses for yield than cutting a function in two - lets
cover generators in detail.
Day 3#
Project Time#
Context Managers#
Although resource management is easier than in other languages, it is
easy enough to mess it up. Clarify the ominous with statement, and
see what is under the hood (spoiler: yield cuts again).
Into The Wild#
Lets leave room on day 3 to …
Try out things. We just went into Labgrid coding; there might well be opportunities to spend more course time.
Cover yet-uncovered material