Skip to content

Commit

Permalink
removed custom support for comments in description.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrentBlanckaert committed Nov 20, 2024
1 parent 57c3079 commit 7aff25d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 40 deletions.
4 changes: 0 additions & 4 deletions tested/dsl/translate_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions tested/languages/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
40 changes: 6 additions & 34 deletions tests/test_functionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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)
Expand Down

0 comments on commit 7aff25d

Please sign in to comment.