Open xp1632 opened 1 month ago
Ref
doctest
unittest
testbook
A Python testing suite that relies on function documentation for tests:
We can use it and print debug statements by:
unittest offers a clean interface and gives test names
so it's easier to find the failing test case
Example function for testing:
In a separate cell, we can write test as:
since we are running this inside jupyterlab
we need to provide argv=[''] and exit=False to unittest.main or it'll error out
argv=['']
exit=False
unittest.main
Example function:
We can refer the notebook name and function name and access the function for testing
notebook name
function name
NodeSpecGen
Ref
doctest
,unittest
, ortestbook
module to test python code in Jupyter lab1.
doctest
for simple functionsA Python testing suite that relies on function documentation for tests:
We can use it and print debug statements by:
2.
unittest
to test in separate test classunittest
offers a clean interface and gives test namesso it's easier to find the failing test case
Example function for testing:
In a separate cell, we can write test as:
since we are running this inside jupyterlab
we need to provide
argv=['']
andexit=False
tounittest.main
or it'll error out3.
testbook
: a library written for testing functions in Jupyter NotebookExample function:
We can refer the
notebook name
andfunction name
and access the function for testingConclusion:
unittest
module to do unit test forNodeSpecGen
doctest
will clutter the code by test documentationtestbook
is specified for Jupyetr Notebook, we'll also need testing when we move this part of code into project