-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tidy: Tweaks to enable pytest on marimo nbs (#3238)
I was really interested in having tests in notebooks (re discussion yesterday), so I played around with it a tiny bit this afternoon. As is, pytest does not work out of the box since: 1. the wrapped functions become Cell instances 2. coroutine detection through the `_is_coroutine` spec should be as an attribute This change enables both of these minor adjustments. Now, pytest will pick up marimo `test_*` functions, but they will fail since directly invoking a cell is currently not allowed. I put in a little unit test to fight against a possible regression until such time when a top level fn spec is enabled (see #2293). @akshayka OR @mscolnick --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
24cd269
commit 50e6285
Showing
9 changed files
with
70 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
import marimo | ||
|
||
app = marimo.App() | ||
|
||
|
||
@pytest.mark.xfail( | ||
reason=( | ||
"Invoking a cell is not directly supported, and as such should fail " | ||
"until #2293. However, the decorated function _should_ be picked up " | ||
"by pytest. The hook in conftest.py ensures this." | ||
), | ||
raises=RuntimeError, | ||
strict=True, | ||
) | ||
@app.cell | ||
def test_cell_is_invoked(): | ||
assert True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters