Uploaded July 2021 | Updated September 2026, 2 weeks ago
Let's write good unit tests for your Python code, using unittest tool, which is a standard Python module for testing. In this example, I apply the assertEqual method which tests your Python function in application code.
In this video I cover the following steps in the domain of Unit testing.
- Write tests
- Setup tests
- Best practices
Unit testing is a method by which components of source code are tested for robustness with coerced data and usage methods to determine whether the component is fit for the production system.
Most companies and teams require their code to be tested. If you want to take a responsible role on big projects, then you are going to need to know how to test.
When you write good tests for your code it gives you more confidence that your updates and refactoring do not have any unexpected impact or break your code anyway.
For example, if you update a function in your project, those changes may have actually broken several sections of your code even if that function itself is still working. It is a very important part of MLOps and DevOps in Python.
Good unit test will make sure that everything is still working as it should.
In this video I am demonstrating how to prepare a simple Unit test in Python for a short Python application consisting of four functions - add, subtract, divide, and multiply.
Sections of the video:
0:00 - Intro to Unit Tests in Python
1:34 - Print Statement is not very good
2:10 - Step 1. Create a test module
2:42 - Step 2. Import the code as a module
3:16 - Step 3. Create a Test Class
3:35 - Step 4. Create a Class test method
4:37 - Step 5. Run our first Unit test
4:47 - Step 5.1. Run without __main__
5:34 - Step 5.2. Run with __main__
6:42 - Step 6. What if our test fails
7:11 - Step 7. Test edge cases
7:52 - Step 8. Add more test methods
9:13 - Step 9. Run multiple unit tests
10:07 - Final Word.
To learn more about the implementation of unit testing, read this documentation: docs.python.org/3/library/unittest.html
The detailed instructions how to write and setup Unit tests, as it is represented in this video, are provided in my Github notes here: github.com/vb100/MLOps-Notes
To write good Unit tests in Python you should have at least basics of Python programming, OOP (Object Oriented Programming) understanding, and the business logic of testing purposes.
#unittest #pythontesting #testclass
Let's write good unit tests for your Python code, using unittest tool, which is a standard Python module for testing. In this example, I apply the assertEqual method which tests your Python function in application code.
In this video I cover the following steps in the domain of Unit testing.
- Write tests
- Setup tests
- Best practices
Unit testing is a method by which components of source code are tested for robustness with coerced data and usage methods to determine whether the component is fit for the production system.
Most companies and teams require their code to be tested. If you want to take a responsible role on big projects, then you are going to need to know how to test.
When you write good tests for your code it gives you more confidence that your updates and refactoring do not have any unexpected impact or break your code anyway.
For example, if you update a function in your project, those changes may have actually broken several sections of your code even if that function itself is still working. It is a very important part of MLOps and DevOps in Python.
Good unit test will make sure that everything is still working as it should.
In this video I am demonstrating how to prepare a simple Unit test in Python for a short Python application consisting of four functions - add, subtract, divide, and multiply.
Sections of the video:
0:00 - Intro to Unit Tests in Python
1:34 - Print Statement is not very good
2:10 - Step 1. Create a test module
2:42 - Step 2. Import the code as a module
3:16 - Step 3. Create a Test Class
3:35 - Step 4. Create a Class test method
4:37 - Step 5. Run our first Unit test
4:47 - Step 5.1. Run without __main__
5:34 - Step 5.2. Run with __main__
6:42 - Step 6. What if our test fails
7:11 - Step 7. Test edge cases
7:52 - Step 8. Add more test methods
9:13 - Step 9. Run multiple unit tests
10:07 - Final Word.
To learn more about the implementation of unit testing, read this documentation: docs.python.org/3/library/unittest.html
The detailed instructions how to write and setup Unit tests, as it is represented in this video, are provided in my Github notes here: github.com/vb100/MLOps-Notes
To write good Unit tests in Python you should have at least basics of Python programming, OOP (Object Oriented Programming) understanding, and the business logic of testing purposes.
#unittest #pythontesting #testclass










