diff --git a/yardang/tests/test_all.py b/yardang/tests/test_all.py index 0b89b6f..ce9a8a0 100644 --- a/yardang/tests/test_all.py +++ b/yardang/tests/test_all.py @@ -1,6 +1,9 @@ import os from pathlib import Path +import pytest +from typer import Exit + from yardang.build import generate_docs_configuration from yardang.cli import build, debug from yardang.utils import get_config_flex @@ -16,6 +19,24 @@ def test_cli(): debug() +def test_cli_pdb_on_failure(monkeypatch): + class FailedProcess: + returncode = 1 + + @staticmethod + def poll(): + return 1 + + traced = [] + monkeypatch.setattr("yardang.cli.Popen", lambda *_args, **_kwargs: FailedProcess()) + monkeypatch.setattr("pdb.set_trace", lambda: traced.append(True)) + + with pytest.raises(Exit): + build(pdb=True) + + assert traced == [True] + + class TestUseAutoapi: """Tests for use_autoapi parameter handling.""" diff --git a/yardang/tests/test_breathe.py b/yardang/tests/test_breathe.py index 4efc820..afaaaa6 100644 --- a/yardang/tests/test_breathe.py +++ b/yardang/tests/test_breathe.py @@ -431,7 +431,7 @@ class MockResult: monkeypatch.setattr(subprocess, "run", mock_run) - result = run_doxygen_if_needed({"mylib": str(xml_dir)}, quiet=True) + result = run_doxygen_if_needed({"mylib": str(xml_dir)}) assert result == {"mylib": True} assert len(run_called) == 1 assert run_called[0][1] == tmp_path # cwd should be Doxyfile's parent diff --git a/yardang/tests/test_wiki.py b/yardang/tests/test_wiki.py index fd97eed..0fd41d6 100644 --- a/yardang/tests/test_wiki.py +++ b/yardang/tests/test_wiki.py @@ -167,6 +167,23 @@ def test_get_page_title_index_becomes_home(self, tmp_path): title = get_page_title(md_file) assert title == "Home" + def test_get_page_title_missing_file_falls_back_to_filename(self, tmp_path): + from yardang.wiki import get_page_title + + title = get_page_title(tmp_path / "missing-page.md") + + assert title == "Missing Page" + + def test_extract_toctree_entries(self): + from yardang.wiki import extract_toctree_entries + + content = """```{toctree} +--- +overview +```""" + + assert extract_toctree_entries(content) == [(None, "overview")] + def test_convert_filename_to_wiki_format(self): """Test filename conversion for wiki format.""" from yardang.wiki import convert_filename_to_wiki_format