A decorator can be thought of as a function that takes another function as an argument, and extends or wraps other functionality around the decorated function without actually modifying it. Any callable—a function, an instance method of a class, or (in this case) a class method belonging to a class—can be used as the decorating function. In this case, the code coverage test case class is going to define two class methods (AddPropertyTesting and AddMethodTesting) using a decorator function structure in order to add new methods (testPropertyCoverage and testMethodCoverage) to any classes that are decorated with them. Those two methods, since they are nested members of the main code coverage class, ...
The property and method testing decorators
Get Hands-On Software Engineering with Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.