motest
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
uv pip install motest
Usage
Suppose that you have a notebook some_notebook.py that you want to test. Maybe with the following content:
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:
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:
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.
Metadata
Release files for motest 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| motest-0.1.1.tar.gz | 30.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| motest-0.1.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 34.6 kB
Release files / motest-0.1.1.tar.gz
| Download URL | motest-0.1.1.tar.gz |
|---|---|
| Size | 30.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7620e787d814133c5d1a4bbf2e7122118b961069f9f35568b0dfa46b5f65289
|
|
BLAKE2b-256 checksum How to use checksums |
91255dae003f491df1d2b0771ddbaddbf07b7eca648102257c6d728a582791f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.5
|
Release files / motest-0.1.1-py2.py3-none-any.whl
| Download URL | motest-0.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
757b95e4cb3df9794a932c7ce0d70fdd3becd77e01dcd9131ef6270bf6321a0d
|
|
BLAKE2b-256 checksum How to use checksums |
172b2cc0dd6b5edb419c147d98df31e5bd8ea18acf53af5ffe5523723a52e8cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.5
|