========
Overview
========
Convert notebook cells to unittests
* Free software: MIT license
Installation
============
::
pip install celltest
You can also install the in-development version with::
pip install https://github.com/NikZak/celltest/archive/master.zip
Usage
=====
From command line
::
celltest [-h] -f FILES [FILES ...] [-c CALLBACKS [CALLBACKS ...]] [-nio] [-o [OUTPUT]] [-st [STANDARD_TEMPLATE]] [-ct [CUSTOM_TEMPLATE]] [-hf [HEADER]] [-v]
Optional arguments::
-h, --help show help message and exit
-f FILES [FILES ...], --files FILES [FILES ...]
<Required> notebook file(s) to convert
-c CALLBACKS [CALLBACKS ...], --callbacks CALLBACKS [CALLBACKS ...]
callbacks to call after the test file creation (e.g. isort, black, yapf)
-nio, --not_insert_outputs
do not insert cell ouputs in the test file (then outputs are read from notebook during testing)
-o [OUTPUT], --output [OUTPUT]
output file. Defaults to test_[notebook name].py
-st [STANDARD_TEMPLATE], --standard_template [STANDARD_TEMPLATE]
standard template file: 1: default template 2: minimalistic template without checking outputs
-ct [CUSTOM_TEMPLATE], --custom_template [CUSTOM_TEMPLATE]
custom template file
-hf [HEADER], --header [HEADER]
header file. Header to insert in every test file
-v, --verbose increase output verbosity
From notebook cell
::
# CT: ignore
# convert current notebook to unittest
from celltest.cells import CellConvert
CellConvert(callbacks=['isort', 'black', 'yapf']).run()
Accepted parameters to control test flow::
'comment', 'setup', 'ignore_outputs', 'ignore_stderr', 'ignore_stdout', 'ignore', 'ignore_display_data', 'run_all_till_now'
Parameters can be either specified in first line (after the % magic) of the notebook cells (e.g.)::
# CT: ignore_outputs comment "Test ABC method"
or written in cell metadata:
::
{ "celltest :
["ignore_outputs", "comment", "Test ABC method"]
}
In case of conflicts line parameters are prioritised
Accepted callbacks (if installed) to prettify the .py test file::
isort, black, yapf
Documentation
=============
https://celltest.readthedocs.io/
Development
===========
To run all the tests run::
tox
Note, to combine the coverage data from all the tox environments run:
.. list-table::
:widths: 10 90
:stub-columns: 1
- - Windows
- ::
set PYTEST_ADDOPTS=--cov-append
tox
- - Other
- ::
PYTEST_ADDOPTS=--cov-append tox
Changelog
=========
0.0.0 (2020-09-09)
------------------
* First release on PyPI.