svolt863
svolt8634w ago

pytest - best practices

I was wondering what the best practices are related to pytest. I can't run pytest.main() within the marimo notebook (error); and running it in the command line is not working neither (I guess I would have to export it into a classical python file first. Is there a recommend best approach to run tests?
3 Replies
Akshay
Akshay4w ago
Haven’t actually tried implementing tests within a marimo notebook — is that what you’re doing? That’s an interesting idea and something we could look into if so
svolt863
svolt863OP4w ago
yes, I would like to add some asserts while developing but I am not sure how to run them; one approach is to have the assert in one cell, but I would like to embed them into a function and use pytest. Maybe it could be a widget (like Explore Variables) that would run pytest?
Myles Scolnick
@svolt863 we had a user use docstrings for testing - you can check out this half-example notebook: https://github.com/marimo-team/marimo/blob/9a2dee666e157677e2b768064628c3d3c18bd854/marimo/_smoke_tests/doctests.py#L58