A handful of useful general-purpose python decorators.
$ pip install decs
Verify functions inputs and outputs types:
fromdecsimportaccepts, returns@returns(str)@accepts(str)defmy_print(string):
print(string)
returnstringVerify methods inputs and outputs types:
fromdecsimportaccepts, returnsclassSomeClass:
@returns(float)@accepts('self', int, float)defclass_method(self, int_arg, float_arg):
returnint_arg+float_argRepeat test case N times:
fromdecsimportrepeatN=42@repeat(N)deftest_something(arg):
pass