import unittest class TestMath(unittest.TestCase): def test_greater_than_10(self): num = 15 self.assertTrue(num > 10)
import unittest class TestStrings(unittest.TestCase): def test_empty_string(self): s = "" self.assertTrue(len(s) == 0)This code defines a test class TestStrings that contains a test method test_empty_string() which checks whether the length of the string s is 0 using the assertTrue method. Package/library: unittest The unittest module is a built-in package/library in Python that provides a framework for constructing and running tests. It allows developers to write unit tests for their Python code, and helps them to easily identify and fix bugs. The assertTrue method, along with many other assertion methods, is provided by this module.