From f2b9f47e0964b111c03695fda147b850141259ce Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Sun, 27 Sep 2026 15:16:41 +0200 Subject: [PATCH] test(cli): add tests for Python force overwriting Added a test to the CLI test file for the documentation generation error. --- tests/unit/cli/test_python.py | 47 +++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/tests/unit/cli/test_python.py b/tests/unit/cli/test_python.py index 70891de..d15e037 100644 --- a/tests/unit/cli/test_python.py +++ b/tests/unit/cli/test_python.py @@ -16,6 +16,8 @@ import pathlib import pytest +import tempfile + from jcloud_docsgen.cli.cli import create_argument_parser from jcloud_docsgen.cli.cli import main as cli_main from jcloud_docsgen.cli.languages.python import parse_sections_list @@ -174,15 +176,40 @@ def test_sections_success(): def test_docs_generation(expectdir): with expectdir('python_project') as output_dir: output_dir: pathlib.Path + (output_dir / 'test_dir').mkdir() input_dir = pathlib.Path(__file__).parent / 'python_project/project' - cli_main( - [ - 'python', - '-s', - 'params', - 'docstring', - '-HTo', - str(output_dir), - str(input_dir), - ] + assert ( + cli_main( + [ + 'python', + '-s', + 'params', + 'docstring', + '-HTfo', + str(output_dir), + str(input_dir), + ] + ) + == 0 + ) + + +def test_docs_generation_error(): + with tempfile.TemporaryDirectory() as output_dir: + output_dir = pathlib.Path(output_dir) + (output_dir / 'test_dir').mkdir() + input_dir = pathlib.Path(__file__).parent / 'python_project/project' + assert ( + cli_main( + [ + 'python', + '-s', + 'params', + 'docstring', + '-HTo', + str(output_dir), + str(input_dir), + ] + ) + == 1 )