Here, I am going to talk about doing a basic unit test for Python. Now, a unit is a small piece of code in a larger script. A unit could be a method, function, module, class, or small collection of related classes. An automated unit test is a programming test that is designed by a human programmer which runs without any intervention and returns a pass or fail condition based on what results are produced by a unit you are testing. A unite test should not require usage of a filesystem, database, or network.
A unit test will probably include assertions: methods to validate an output the testing it with a known 'correct' response. Here are some commonly used assertions:
a == b
bool(x) is True
bool(x) is False
a is b
x is None
a in b
.assertIsInstance() all have opposite methods that can be activated by adding the keyword not: .assertIsNot(), .assertIsNotNone(), etc.