Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions yardang/tests/test_all.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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."""

Expand Down
2 changes: 1 addition & 1 deletion yardang/tests/test_breathe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions yardang/tests/test_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading