Unit Test, Pytest and doctest practical course for python programmers
You want to write structured and high-quality unit tests for your Python code? You want to test databases, foreign APIs and foreign code? You want to recognize bad and useless unit tests and PyTests right away and turn them into good unit tests using proven patterns? You finally want to know how Test-Driven-Development looks like in practice and how you can use TDD in a reasonable way? Then look no further. The Python Unit Testing Practical Seminar is ideal for all Python programmers who want to learn Unit Testing, PyTest and Doctest in an efficient and practical way using clear examples and tasks, so that they can test Python code cleanly and improve it significantly. Learn more about this Unit Test practical seminar...
Benefits
- Quick and effective introduction to Unit Test, Pytest and Doctest
- Practical introduction to Test-Driven-Development (TDD)
- Best practices for Testable Design, Clean Test and Test Smell
- Advanced techniques such as Test Double
- Significantly improve code quality through good testing
By means of many examples and exercises you will learn the most important Python testing frameworks (Unit Test & Pytest) as well as advanced techniques like TDD from a practical point of view and how you can use them successfully in your current project. You will also learn and apply golden rules for clean testing and code. You will improve the quality and the goodness of your Python production code and shorten the development time.
Contents
The course covers a selection of the following topics:
- Test Structure
- Name Conversion
- Test Lifecycle
- Test Data
- Features von pytest
- Exceptions in pytest
- unittest
- Test with Fixtures
- Parameterized Test
- Test Double
- doctest
- Test-Driven-Development
- Test Smells Catalog
- Test Readability
- Test Maintainability
- Test Trustworthiness
For more details, please see the agenda below.
Prerequisites
The Unit Test in Python seminar at the Munich Coding Academy is aimed at programmers with basic Python knowledge, comparable to our Python for programmers course. It does not require any knowledge of old unit testing versions.
Individuell: wir gehen gezielt auf Dich ein und berücksichtigen Deine Vorkenntnisse, Wunschthemen und Schwerpunkte
Strukturiert und leicht verständlich
Bringe deine Karriere, Studium oder Ausbildung auf die nächste Stufe: mit Zertifikat
Sicher und eigenständig Programme entwickeln (ob privat, beruflich oder für dein Startup)
Viel, viel, viel Praxis: sofort anwendbare Ergebnisse
kleine Gruppen: max. 8 Teilnehmer im 3-Tages-Kurs max. 15 Teilnehmer im Online-Coaching
Von Experten nach der Raed- Methode® entwickelt & auf die Anforderungen von Tech-Unternehmen im Jahr 2020 ausgerichtet
E-Mail-Support auch nach Ende des Kurses
Description
This three-day course provides an introduction and deep dive into testing Python code. The course is intended for users with prior experience in Python who want to develop a better understanding of testing their own code against failures and regressions, and of improving the test coverage of existing code bases. The participants get instructive problems to solve using the newly learned techniques.
-Why should I test my code?
-How can tests help in pinpointing problems?
-What makes a good test and how can I write it?
-How can I test code with external dependencies?
-How can I avoid them?
-How can I avoid writing (too much) test code?
-How can I keep my test suite maintainable in the future?
-When and why would I use “unittest”, “pytest” or “doctest”?
What do you learn on the first day?
You will learn how to write your first unit testing program in Python. We start slowly and look at the should/actual principle of testing frameworks. You learn how the test structure should look like, how you should name your test methods and how you can find the test data. The equivalence classes and boundary value techniques are suitable for this. You master the syntax and semantics of Unit Test and PyTest. After this day, you will be able to write and use good unit tests for your Python code.
What do you learn on the second day?
On the second day you learn more advanced techniques with Pytest, Unit Test and doctest. For example, you learn how to test database and third-party APIs by simulating their code. This is what the Test Double technique is for. Test Double is a collective term for 5 techniques: Dummy, Fake, Stub, Spy and Mock. You will learn how to use these techniques with the Python test frameworks.
What do you learn on the third day?
The last Unit Testing training with Java is about how to write good tests. Here you will learn the SOLID principles for testable design. Then we look at the Test-Driven-Development (TDD) technique. TDD implements the "Test First: Test code before Production code" method.
TDD slows down the development speed at the beginning, but later on it catches up massively in speed and is definitely more advantageous than writing the tests afterwards. After all, Clean Code is largely based on writing unit tests before production code, so you have to think about the production code in a fundamental way! You will also learn the important rules for writing meaningful and good tests and the best practices. This will help you recognise the so-called "test smells".
Test smells is a term for bad tests that bring more disadvantages than advantages. There is a long catalogue for this, which divides the test smells into 3 categories and in each category there are several test smells cases. We look at the most important test smells cases.
YOUR TRAINERS
The Unit Test course for Python programmers is conducted by one of the following trainers:

Dr. Stefan Behnel
Expert: Python, Pytest, Unit Test und TDD, Clean Code, Clean Software Architektur, Fast Python, Cython
- Doctorate at the TU Darmstadt as Dr. Ing. in Software Architecture
References: 15 years of experience as a consultant, software developer and software architect in the financial services, automotive, publishing and tourism industries in the field of high-performance Python and open source, main developer of Cython, the data science library PANDA is based on Cython. Python training for Draeger, Apple, Sky Deutschland, IT companies, ...

Dr. Matthias Hölzl
Expert: Artificial Intelligence, Python, C++, Java, JavaScript, Clean Code & Software Architecture
- Doctorate at LMU in the field of Software Engineering
References: 30 years of teaching and industrial experience. Of which 18 years at Ludwig-Maximilians-Universität Munich, most recently as Professor for Software and Computational Systems Engineering. Training, technical coaching for machine learning, deep learning, process automation as well as review and improvement of software architecture in large IT projects. Python and Java trainings for Deutsche Bank, BMW, BA, VKB, etc. Editor and author of several books at Springer-Verlag and author of numerous scientific publications.

Allaithy Raed
Expert: Java, Python, Clean Code, Clean SW-Architecture, Refactoring, Testing, Train The Trainer
- Doctorate at LMU in the field of programming languages (2022).
References: 17 years of teaching and industry experience, thereof 12 years lecturer at the Ludwig-Maximilians-University Munich for Java, Python, Efficient Algorithms, Multiple awardsfor outstanding teaching at the LMU, book author for Java & soon Python at Springer and Orelly Verlag, developer of the RAED-Teaching Method®, Train the Trainer instructor, team training in Java and Python for BMW, VW, BA, SIEMENS, AGFA-Healthcare, TÜV Süd, Schufa AG, ..

Prof. Dr. Peer Kröger
Expert: Artificial Intelligence, Data Science, Big Data, SQL/NoSQL Database, Python, Java
- Doctorate at LMU in the field of Database and Data Science
References: Many years of practical experience in the implementation of data science projects as well as in consulting and training in the automotive industry, financial service providers and SMEs, among others. Approx. 150 peer-reviewed publications (cited over 8000 times) on the topic of data science, data mining, machine learning and AI. Member of the AI competence centre Munich Center for Machine Learning (MCML) at LMU Munich and professor for information systems and data mining at CAU Kiel.
CERTIFICATE
Of course, you will receive a certificate as a participant in the Python Unit Test Course for Programmers. The prerequisite for this is the complete participation in all course units and programming tasks and the successful programming of a small final project. However, this will be more fun than stressful for you after this intensive unit testing course.
AGENDA
The agenda is written in English due to the numerous technical terms. Descriptions and course material are in German. You can book the course either in German or English.
All seminar contents are individually adapted to the wishes of our participants. They can vary depending on the level of knowledge and will be defined together with the seminar leader on day 1. In this Python unit test seminar you can choose from the following topics:
Python Unit Testing Day 1
Introduction:
- Test Motivation
- Test Frameworks
- pytest
- unittest
- doctest
Generic Rules:
- Test Structure
- Test Life Cyce
- The AAA-Rule
- Name Conversions
- Test Data
- Happy Path
- Exception Path
- Equivalence classes
- Test Strategy
pytest
- install pytest
- Your first pytest
- assert statement
- failed test
- pytest features
- Expected exceptions
- Marking test methods
- Selection of test methods
- Tests with error handling
Fixture
- what is fixture?
- Reuse of fixture
- config.py
- Multiple fixtures
- Scope of fixtures
- predefined fixtures
unittest
- xUnit-Framework
- unittest
- Fixtures
- Test Cases
- Test Suites
- Why pytst over unittest?
Python Unit Testing Day 2
Test Double
- Motivation
- Testing Database?
- Dummy
- Fake
- Stub
- Spy
- Mock
doctest
- why doctest?
- Executable documentation
- Executable specification
- pytst vs. unites vs. doctest
Python Unit Testing Day 3
Test Driven Development
- Motivation
- RED
- GREEN
- REFACTORING
- Baby Steps
- TDD Advantages
Testable Design
- SOLID Principle
- Single Responsibility
- Open Close
- Liskov Substitution
- Interface Segregation
- Dependency Inversion
Clean Test
- Clean Test Rules
- Test Readability
- Test Maintainability
- Test Trustworthiness
- Test Smells Catalog