Files
doc-forge/tests/cli/test_generate.py

36 lines
813 B
Python

from pathlib import Path
from docforge.cli.main import cli
def test_generate_command(cli_runner):
with cli_runner.isolated_filesystem():
cwd = Path.cwd()
# Create package structure
pkg = cwd / "testpkg"
pkg.mkdir()
(pkg / "__init__.py").write_text("")
(pkg / "mod.py").write_text("def f(): ...\n")
docs_dir = cwd / "docs"
result = cli_runner.invoke(
cli,
[
"generate",
"--module",
"testpkg",
"--docs-dir",
str(docs_dir),
],
)
assert result.exit_code == 0
md = docs_dir / "testpkg" / "mod.md"
assert md.exists()
content = md.read_text()
assert "::: testpkg.mod" in content