import unittest class MyTest(unittest.TestCase): def __init__(self, methodName='runTest', param=None): super().__init__(methodName) self.param = param def test_param_is_not_none(self): self.assertIsNotNone(self.param) if __name__ == '__main__': unittest.main()
import unittest from my_module import MyObject class MyTest(unittest.TestCase): def __init__(self, methodName='runTest'): super().__init__(methodName) self.obj = MyObject() def test_obj_is_not_none(self): self.assertIsNotNone(self.obj) if __name__ == '__main__': unittest.main()In this example, we are creating a new `MyTest` class that extends the `TestCase` class. We have added an `__init__` method that initializes a new instance of `MyObject` and sets it to `self.obj`. In the `test_obj_is_not_none` method, we use the `assertIsNotNone` assertion to verify that `self.obj` is not None. In conclusion, the package library used in these examples is the `unittest` package that is part of the Python standard library.