Skip to content

Commit 0da9c25

Browse files
authored
chore: deflake tmpdir cleanup in tests (#3573)
1 parent 420e110 commit 0da9c25

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

docs/guides/editor_features/watching.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ Guide](module_autoreloading.md)
4545
!!! note
4646
Support for watching data files and automatically refreshing cells that depend on them is coming soon. Follow along at <https://github.com/marimo-team/marimo/issues/3258>
4747

48-
## Developing in WASM mode
48+
## Hot-reloading WebAssembly notebooks
49+
50+
Follow these steps to develop a notebook using your own editor while
51+
previewing it as a [WebAssembly notebook](../wasm.md) in the browser. This lets
52+
you take advantage of local development tools while seeing the notebook as it
53+
appears when deployed as a WebAssembly notebook.
4954

50-
Follow these steps to develop a notebook using your own editor, while previewing it as a WebAssembly notebook in the browser. This lets you take advantage of local development tools while seeing the notebook as it appears when deployed as a [WebAssembly notebook](../wasm.md).
5155
```bash
52-
# in one terminal, start a watched edit session
56+
# in one terminal, start a watched edit (or run) session
5357
marimo edit notebook.py --watch
5458

5559
# in another terminal
@@ -58,4 +62,4 @@ marimo export html-wasm notebook.py -o output_dir --watch
5862
# in a third terminal, serve the WASM application
5963
cd path/to/output_dir
6064
python -m http.server # or a server that watches for changes
61-
```
65+
```

tests/conftest.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,16 @@ def executing_kernel() -> Generator[Kernel, None, None]:
229229
mocked.teardown()
230230

231231

232+
def _cleanup_tmp_dir(tmp_dir: TemporaryDirectory) -> None:
233+
try:
234+
# Tests shouldn't care whether temporary directory cleanup
235+
# fails. Python 3.10+ has an ignore_cleanup_error argument,
236+
# but we still support 3.9.
237+
tmp_dir.cleanup()
238+
except Exception:
239+
pass
240+
241+
232242
@pytest.fixture
233243
def temp_marimo_file() -> Generator[str, None, None]:
234244
tmp_dir = TemporaryDirectory()
@@ -258,7 +268,7 @@ def __(mo):
258268
f.write(content)
259269
yield tmp_file
260270
finally:
261-
tmp_dir.cleanup()
271+
_cleanup_tmp_dir(tmp_dir)
262272

263273

264274
@pytest.fixture
@@ -301,7 +311,7 @@ def __(mo):
301311
f.write(content)
302312
yield tmp_file
303313
finally:
304-
tmp_dir.cleanup()
314+
_cleanup_tmp_dir(tmp_dir)
305315

306316

307317
@pytest.fixture
@@ -330,7 +340,7 @@ async def __():
330340
f.flush()
331341
yield tmp_file
332342
finally:
333-
tmp_dir.cleanup()
343+
_cleanup_tmp_dir(tmp_dir)
334344

335345

336346
@pytest.fixture
@@ -372,7 +382,7 @@ def __():
372382
f.flush()
373383
yield tmp_file
374384
finally:
375-
tmp_dir.cleanup()
385+
_cleanup_tmp_dir(tmp_dir)
376386

377387

378388
@pytest.fixture
@@ -416,7 +426,7 @@ def __():
416426
f.write(content)
417427
yield tmp_file
418428
finally:
419-
tmp_dir.cleanup()
429+
_cleanup_tmp_dir(tmp_dir)
420430

421431

422432
@pytest.fixture
@@ -449,7 +459,7 @@ def temp_md_marimo_file() -> Generator[str, None, None]:
449459
f.write(content)
450460
yield tmp_file
451461
finally:
452-
tmp_dir.cleanup()
462+
_cleanup_tmp_dir(tmp_dir)
453463

454464

455465
@pytest.fixture
@@ -486,7 +496,7 @@ def __():
486496
f.write(content)
487497
yield tmp_file
488498
finally:
489-
tmp_dir.cleanup()
499+
_cleanup_tmp_dir(tmp_dir)
490500

491501

492502
@pytest.fixture
@@ -518,7 +528,7 @@ def __():
518528
f.write(content)
519529
yield tmp_file
520530
finally:
521-
tmp_dir.cleanup()
531+
_cleanup_tmp_dir(tmp_dir)
522532

523533

524534
# Factory to create ExecutionRequests and abstract away cell ID

0 commit comments

Comments
 (0)