MCPcopy Index your code
hub / github.com/marimo-team/marimo / test_read_pyproject_from_script

Function test_read_pyproject_from_script

tests/_utils/test_scripts.py:13–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11
12
13def test_read_pyproject_from_script():
14 script = textwrap.dedent(
15 """
16 # /// script
17 # requires-python = ">=3.11"
18 # dependencies = ["polars"]
19 # [tool.marimo]
20 # formatting = {line_length = 79}
21 # ///
22
23 import marimo
24 """
25 )
26
27 pyproject = read_pyproject_from_script(script)
28 assert pyproject is not None
29 assert pyproject["requires-python"] == ">=3.11"
30 assert pyproject["dependencies"] == ["polars"]
31 assert pyproject["tool"]["marimo"]["formatting"]["line_length"] == 79
32
33 # Test no script block
34 script = "import marimo"
35 assert read_pyproject_from_script(script) is None
36
37 # Test multiple script blocks
38 script = textwrap.dedent(
39 """
40 # /// script
41 # requires-python = ">=3.11"
42 # ///
43
44 # /// script
45 # dependencies = ["polars"]
46 # ///
47 """
48 )
49 with pytest.raises(ValueError, match="Multiple script blocks found"):
50 read_pyproject_from_script(script)
51
52 # Test invalid TOML
53 script = textwrap.dedent(
54 """
55 # /// script
56 # invalid toml content
57 # ///
58 """
59 )
60 with pytest.raises(ValueError):
61 read_pyproject_from_script(script)
62
63
64def test_read_marimo_config_from_script():

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…