Files
skills/skills/python/sonde/tests/test_loader.py
T
2026-10-19 14:16:52 -07:00

30 lines
1.0 KiB
Python

import pytest
from sonde.loader import load, module_docstring, search_paths
def test_search_paths_covers_flat_and_src_layouts(tmp_path):
(tmp_path / "src").mkdir()
assert search_paths(tmp_path) == [str(tmp_path), str(tmp_path / "src")]
assert search_paths(tmp_path / "src") == [str(tmp_path / "src")]
def test_load_walks_a_dotted_path(repo_root):
assert load(repo_root, "sonde.loader").name == "loader"
assert load(repo_root, "sonde.artifacts.Artifact").name == "Artifact"
def test_a_missing_package_names_where_we_looked(repo_root):
with pytest.raises(ValueError, match="no package 'nosuchpkg' under"):
load(repo_root, "nosuchpkg")
def test_a_missing_member_names_the_failing_segment(repo_root):
with pytest.raises(ValueError, match=r"failed at 'Ghost' under 'sonde\.loader'"):
load(repo_root, "sonde.loader.Ghost")
def test_module_docstring_of_a_script_without_one():
assert module_docstring("x = 1\n") == ""
assert module_docstring('"""Summary."""\nx = 1\n') == "Summary."