marimo
marimo copied to clipboard
pytest fixtures don't work
Describe the bug
Consider this notebook with 2 cells:
@pytest.fixture
def mock_data():
yield 12
and
def test_process_data_default_mock(mock_data):
assert mock_data == 12
When I try to run the test in the second cell, it says mock_data can't be found, even though it's definitely in the notebook's scope.
Similar issue: #5231 (but that's more of a feature request, asking to be able to define the fixture and run the test in the same cell)
Will you submit a PR?
- [ ] Yes
Environment
Replace this line with the output of marimo env. Leave the backticks in place.
Code to reproduce
https://marimo.app/l/xzbja4 (marimo 0.16.2 as of this writing)
Or:
import marimo
__generated_with = "unknown"
app = marimo.App()
@app.cell
def _():
import marimo as mo
import pytest
return (pytest,)
@app.cell
def _(pytest):
@pytest.fixture
def mock_data():
yield 12
return
@app.function
def test_process_data_default_mock(mock_data):
assert mock_data == 12
@app.cell
def _():
return
if __name__ == "__main__":
app.run()
This is something we don't support yet (just due to complexity that we are reluctant to add to the runtime). It is something we may add in the future, but not in the near term due to prioritization.
This is something we don't support yet (just due to complexity that we are reluctant to add to the runtime). It is something we may add in the future, but not in the near term due to prioritization.
Understood. Just FYI this feature would be very welcome-- from my perspective a testing environment which doesn't support fixtures is of pretty limited utility.