Developer advocate / Data Scientist - support open-source and building the community.
Python Zero to Heros
Online Absolute Beginner Python Tutorials
Every Sunday 2pm (UK time/ BST)
Get this slide deck:
Python objects - int, float, str, list, dict, bool
Control flows - if-else, for loop, while loop
Functions, modeuls, classes and decorators
strings operations and regex with re
pytest with fixtures and mock
python linters & auto-formatters
Recap:What is Unit test
First your program are structured in units: e.g. functions, classes, modules
Making sure a functions works as it is supposed to locks that pieces of code in place
Most basic piece of testing, to test everything we need other tests. e.g. integration testing, end-to-end testing etc
What is TDD?
Test-driven development cycle
- Add a test
- Run all tests and see if the new test fails
- Write the code
- Run tests
- Refactor code
Pros of TDD
- Codes are well structured and clean
- Easy to maintain
- Easy to document
- Design in the users' perspective
Cons of TDD
- Time upfront to write tests
- Short sighted
- Refactoring may be a pain
- Bad tests lead to false sense of secutity
But also read 5 Excuses for Not Doing TDD, Debunked
When to TDD?
When your task can be break down into isolated modules.
TDD lends itself really well to when you have a pure logic function that you need to write. When the work you need to do has a clearly defined set of expected inputs and outputs, it's a great signal that you should use TDD to build out your tests and code.
or not to TDD?
- If you are starting a project fresh, breakdown tasks in units and TDD
- Always add unit tests to exsting codebase (unless the code is not to be maintained)
- Don't be fustrated by writing tests
Sunday 2pm (UK time/ BST)
There are also Mid Meet Py every Wednesday 1pm
Testing month in June
By Cheuk Ting Ho