Course Info
Main advantage | Learning code maintenance is crucial, especially when introducing new changes can be slow and often results in numerous bugs. Your developers will start test their code or they’ll do it much better than before after this course. This will speed up your team and they’ll introduce less bugs with each change. |
Duration | a) half-days: 5 days x 4 hours (including breaks) b) full-days: 3 days x 7 hours (including breaks) |
Format | workshop (70% workshop / 30% lecture) |
Venue | a) online or b) client’s office or other place chosen by the client, in Europe |
Enrollment | in-house course for a group of people within one company |
Group size | up to 10 delegates |
Course language | English, Polish or both during the same training |
Course Syllabus
I. SOLID Principles
We start from a discussion on SOLID principles that makes code easier to read and maintain. This part is supplemented with exercises demonstrating how (and how not) to apply SOLID principles in Python. This will be helpful in the second step of each iteration in TDD (as well as BDD), that is writing production code.
II. Code Refactoring
The third step of each iteration in both TDD and BDD is refactoring; this involves making code easier to read and maintain without changing its functionality.
In this part, we cover all building blocks (or actions) of refactoring. We introduce the concept of code bad smells that help you find opportunities for correct refactoring and avoid “endless refactoring back and forth”.
III. Builtin Testing Frameworks
First step of each iteration in TDD is writing a test.
We start from a discussion if and why writing tests is beneficial. Contrary to intuition, less bugs is only one of the advantages of covering code with tests.
We usually use a framework that makes writing tests easier. We show how to use the most popular testing framework – unittest.
We also introduce very agile doctest library which help you test, and at the same time, document small utility functions without all the burden and long-winded unittest.
IV. Test Driven Development
After short theoretical introduction to TDD, we solve Katas – programming challenges like RecentlyUsedList or BowlingGame. Katas are simple exercises that let you focus on the TDD methodology rather than fighting with language, IDE or business logic.
We start from a live coding – the instructor shows how you can solve a Kata using TDD. Participants ask questions and discuss with the instructor and other participants. Later on, we move to another Kata. This time participants do the exercise in pairs (pair programming).
V. Test Isolation and Mocking
Test isolation and mocking is covered during second day of the training. We introduce great unittest.mock builtin library (or mock backport if you work on Python 2). It helps you isolate your tests from system calls, filesystem, databases, external APIs or any other resources. We study the most common cases.
Mocking is also an essential part of outside-in development which is covered during the last day.
VI. Testing Web Applications
Testing Web Application let you focus on one of common cases when you need to test a web application written using a framework. For simplicity, this framework is Flask unless you work in Django, in which case we focus on Django’s own challenges.
A number of tools are discussed, Selenium and the built-in Flask client are two examples. However, we introduce and focus on WebTest which is other client and is much faster than Selenium.
VII. Overview of Other Testing Approaches and Code Coverage
At the end of the second day, the instructor introduces other testing approaches. We discuss property-based testing (with hypothesis-python library) and mutation testing (with MutPy). We also introduce a concept of code coverage and show how to configure it.
VIII. Outside-in Development
Most of the time, programmers develop their code inside-out. They start from the simplest functions and tools (inner or lower modules), maybe even they test them, and built outer (or higher) modules upon them. For example, they first implement backend, and then frontend. This is dictated by the fact that the outer modules depend on the lower ones, for example frontend depends on backend. Therefore, you cannot test outer ones without inner ones.
However, this results in bad interfaces, because outer modules are written to match inner modules instead of required behavior. Outside-in development forces you to first implement higher modules, test them mocking the lower modules, and then focus on the inner modules. This results in better interfaces between modules.
IX. Plain-Text Stories in Gherkin
We introduce a special domain specific-language based on English natural language that helps you write acceptance tests understandable for non-programmers. If you have ever heard about Cucumber, you’ll be astonished that there is a very similar framework in Python called behave.
X. nose2.tools.such DSL
We introduce another style of BDD – executable specification written with nose2.tools.such plugin, a DSL in Python.
We also introduce nose2 tool to run unit tests and show how you configure it and enable nose2.tools.such plugin.
XI. Behaviour Driven Development
Behave Driven Development is an extension of TDD. After a short theoretical introduction, we show on a case study how you can use behave and nose2.tools.such with BDD. We also show how professional edition of PyCharm supports BDD and behave framework.
Collaboration Process
- Form. You fill out the form at the bottom of the page.
- Free Consultation. We arrange a free, non-binding online meeting that should last no longer than 50 minutes. From the first contact, full confidentiality is observed, and if necessary, we can start by signing an NDA. The purpose of this conversation is to thoroughly discuss your situation and needs, so we can prepare a solution for you in the next step.
- Solution Proposal + Follow-up Consultation. After the consultation, we analyze your situation and prepare a tailored solution proposal (training and/or consulting). We discuss this proposal during another free consultation.
- Formalities. Signing the contract and making the payment (prepayment). The training date is reserved upon payment.
- Training Sample. If needed, we can precede the main training with a 60-minute training sample to ensure that it is worth your while to cooperate with us.
- Training and/or Consulting Activities.
- Post-training Support – tailored individually to your needs.
References
Very inspiring training. I really appreciate the way Chris managed to walk us through the complex world of machine learning using Python. Good course materials updated real time. Highly recommend.
Krzysztof Gębal
Finance Director at DNB Bank Polska S.A.
Well prepared training and reasonably passed knowledge, thanks to which we develop better services.
Arkadiusz Baraniecki
Infrastructure Team Manager at allegro.pl
Chris recently taught a four day class on Machine Learning with Python four our team. The class was very good with the right balance of theory and practice. I cannot think of a better way to give a four day class about such an extensive topic.
Nicolas Leveroni
Head of Krakow Product Control Analytics at HSBC