generate test command fixed

This commit is contained in:
2026-01-20 23:59:51 +05:30
parent b497c5d2e9
commit 5c8d9dcc9c

View File

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