From 7aff25d750d20ced88b8ccac27c79bbb65f74c19 Mon Sep 17 00:00:00 2001 From: breblanc Date: Wed, 20 Nov 2024 15:37:35 +0100 Subject: [PATCH] removed custom support for comments in description. --- tested/dsl/translate_parser.py | 4 ---- tested/languages/generation.py | 9 ++++++-- tests/test_functionality.py | 40 +++++----------------------------- 3 files changed, 13 insertions(+), 40 deletions(-) diff --git a/tested/dsl/translate_parser.py b/tested/dsl/translate_parser.py index 29c03ba5..62811aef 100644 --- a/tested/dsl/translate_parser.py +++ b/tested/dsl/translate_parser.py @@ -640,10 +640,6 @@ def _convert_testcase(testcase: YamlDict, context: DslContext) -> Testcase: assert isinstance( dd, str ), f"The description.description field must be a string, got {dd!r}." - line_comment = extract_comment(dd) - if line_comment and dd.endswith(line_comment): - dd = dd[:-len(line_comment)].rstrip().rstrip("#").rstrip() - df = description.get("format", "text") assert isinstance( df, str diff --git a/tested/languages/generation.py b/tested/languages/generation.py index 7be0d2e3..9fbe6656 100644 --- a/tested/languages/generation.py +++ b/tested/languages/generation.py @@ -146,13 +146,18 @@ def get_readable_input( format_ = bundle.config.programming_language text = generate_statement(bundle, case.input) text = bundle.language.cleanup_description(text) + + if case.line_comment: + text = f"{text} {bundle.language.comment(case.line_comment)}" else: assert isinstance(case.input, LanguageLiterals) text = case.input.get_for(bundle.config.programming_language) format_ = bundle.config.programming_language - if case.line_comment: - text = f"{text} {bundle.language.comment(case.line_comment)}" + if case.line_comment: + text = f"{text} {bundle.language.comment(case.line_comment)}" + + # If there are no files, return now. This means we don't need to do ugly stuff. if not case.link_files: diff --git a/tests/test_functionality.py b/tests/test_functionality.py index 9b5d3d7f..c7e5cafb 100644 --- a/tests/test_functionality.py +++ b/tests/test_functionality.py @@ -86,21 +86,9 @@ def test_global_comment( f"{comment_start} The name of the global variable" ) -@pytest.mark.parametrize( - "language, comment_start", - [ - ("bash", "#"), - ("python", "#"), - ("kotlin", "//"), - ("csharp", "//"), - ("java", "//"), - ("c", "//"), - ("javascript", "//"), - ("haskell", "--"), - ], -) +@pytest.mark.parametrize("language", ALL_LANGUAGES) def test_global_no_comment( - language: str, comment_start: str, tmp_path: Path, pytestconfig: pytest.Config + language: str, tmp_path: Path, pytestconfig: pytest.Config ): conf = configuration( pytestconfig, "global", language, tmp_path, "plan.yaml", "correct" @@ -110,25 +98,11 @@ def test_global_no_comment( description = updates.find_next("start-testcase") assert "description" in description and "description" in description["description"] - assert not description["description"]["description"].endswith( - f"{comment_start} The name of the global variable" - ) + assert description["description"]["description"] == "Hallo" -@pytest.mark.parametrize( - "language, comment_start", - [ - ("bash", "#"), - ("python", "#"), - ("kotlin", "//"), - ("csharp", "//"), - ("java", "//"), - ("c", "//"), - ("javascript", "//"), - ("haskell", "--"), - ], -) +@pytest.mark.parametrize("language", ALL_LANGUAGES) def test_global_comment_description( - language: str, comment_start: str, tmp_path: Path, pytestconfig: pytest.Config + language: str, tmp_path: Path, pytestconfig: pytest.Config ): conf = configuration( pytestconfig, "global", language, tmp_path, "comment_description_plan.yaml", "correct" @@ -138,9 +112,7 @@ def test_global_comment_description( description = updates.find_next("start-testcase") assert "description" in description and "description" in description["description"] - assert description["description"]["description"].endswith( - f"{comment_start} This is a greeting" - ) + assert description["description"]["description"] == "Hallo # This is a greeting" @pytest.mark.parametrize("lang", EXCEPTION_LANGUAGES)