Metadata-Version: 2.4
Name: nbcheckmate
Version: 0.1.8
Summary: Small package to test code inside a jupyter notebook
Author-email: Paul Chupot <paul.chupot@gmail.com>, Aloys Bernard <aloys.bernard@gmail.com>
Keywords: jupyter,notebook,testing,pytest
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: dill>=0.3.9
Requires-Dist: pytest>=7.1.3

# Nbcheckmate

Nb checkmate is your fellow library that allow you to test functions and variables inside of a notebook. 

## Installation

To install this package, you can use pip:

```
pip install nbcheckmate
```

## Usage

To use this package, you can import it in your Python code:

```python
from nbcheckmate.nbcheckmate import ResultsTests

results = ResultsTests("example", answer=42)
results.save()
print(results.get_results())
```

Create a `tests` directory alongside the notebook or in an ancestor directory,
with a corresponding `test_example.py`. Tests can load the notebook data with
`ResultsTests.load("test_example.pkl")` and inspect its `variables` and `functions`.

Runtime paths are excluded from saved state and reconstructed by `ResultsTests.load()`
on the machine running the tests. This supports saving notebook state on Windows
and testing it on Linux, or the reverse. Use compatible Python and dependency
versions on both machines. Values supplied by the notebook must themselves be
portable: concrete `WindowsPath` or `PosixPath` objects inside variables or captured
function state are not converted automatically.

To run the notebook and tests locally, including in Windows PowerShell:

```sh
python -m pip install . nbclient ipykernel
python -c "import nbformat; from nbclient import NotebookClient; nb = nbformat.read('rugby-premiership.ipynb', as_version=4); NotebookClient(nb, timeout=120, kernel_name='python3').execute()"
python -m pytest -v
```

CI runs on Linux. Windows compatibility is validated locally using the commands above.
