- New `Test` context manager and callable class to easily do assertion testing with easy to understand debug info. This was done mostly for internal use of the package (in the unit testing) and as such, is not well refined. Usage is as:
python
import PlainTools as pt
Example usage of the Test context
with pt.Test.name("pnumber") as t:
Also possible to do:
t.name("pnumber")
x = pt.pnumber(1 / 3)
t(
str(x) == '0.333...',
x.value == 0.333333333333333,
x.period == '3',
x.fraction == (1, 3),
x.type == float,
)
Output: |Test 4(pnumber) = PASS
Example usage of the Test callable
def foo(x):
return x + 5
pt.Test(foo(10), 15)
Output: |Test 21 = PASS