Metadata-Version: 2.4
Name: motest
Version: 0.1.1
Summary: Small cli that allows for more elborate testing inside Marimo
Project-URL: repository, https://github.com/koaning/motest
Project-URL: issue-tracker, https://github.com/koaning/motest/issues
Project-URL: documentation, https://koaning.github.io/motest/
Author: Vincent D. Warmerdam
License: MIT License
        
        Copyright (c) 2025 vincent d warmerdam 
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: marimo
Requires-Dist: pytest
Description-Content-Type: text/markdown

### motest

<img src="https://github.com/koaning/motest/blob/main/testimg.png?raw=true" alt="logo for motest" width="150" align="right">

Small cli that allows for more elaborate testing inside Marimo

> This project was made so I might more easily write elaborate tests in side of Marimo notebooks. It is barely worth the effort because you can also just add the commands together in a Makefile, but it was a fun exercise that led me to learn how pytest can be called directly from Python.

## Installation

```bash
uv pip install motest
```

## Usage

Suppose that you have a notebook `some_notebook.py` that you want to test. Maybe with the following content:

```python
import marimo as mo
import pytest

def add(a, b):
    return a + b

@pytest.mark.parametrize("a,b,c", [(1, 1, 2), (1, 2, 3)])
def test_add(a, b, c):
    assert add(a, b) == c
```

You can test this notebook by running the following command:

```bash
python -m motest some_notebook.py
```

This is what the output will look like:

```
============================= test session starts ==============================
platform darwin -- Python 3.10.14, pytest-8.3.4, pluggy-1.5.0
rootdir: /Users/vincent/Development/motest
configfile: pyproject.toml
plugins: anyio-4.7.0
collected 2 items                                                              

test_some_notebook.py ..                                                   [100%]

============================== 2 passed in 0.11s ===============================
```

## How it works 

The setup is really minimal. We call the `marimo export script` command and write the Python code to a temporary file. We then point `pytest` to this file and do a cleanup after the tests are done. The status code is returned to the caller and you are also able to pass any `pytest` arguments to the command as well.

You could accomplish the same thing by adding this to a `Makefile`:

```Makefile
test:
    marimo export script -o test_some_notebook.py some_notebook.py
    python -m pytest test_some_notebook.py
```

But it kind of felt nicer to have a dedicated command for this.
