This tutorial is currently under construction.
This tutorial was built using Python 3.6
If you are starting to improve your Python development skills, the one aspect that must be up to scratch is your ability to test your code. Unit testing your code can help to improve the confidence you have whenever you are trying to make any patches, bug fixes or just changes in general.
If your tests adequately test that your code behaves the way you expect it to, whenever you make a change, you can retest and ensure that your code still behaves the way you expect it with your incorporated changes. If the tests fail then you know that you will have to make further changes until your tests do pass.
In this tutorial I am going to be showing you the basics of unit testing in Python.
Let’s envision that we have a very simple python module that features a
If we wanted to test this using the
unittest module we could do something like so:
When we run this using
python3.6 test_mymodule.py you should see the following output:
I hope you found this tutorial useful, if you wish to leave feedback or request more information then please let me know in the comments section below!