Skip to content

Commit

Permalink
Merge pull request #489 from dodona-edu/fix/newlines
Browse files Browse the repository at this point in the history
Fix newline normalisation for empty strings
  • Loading branch information
niknetniko authored Jan 9, 2024
2 parents ee807a8 + 9187558 commit d0906b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tested/dsl/translate_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ReturnOracle:


def _ensure_trailing_newline(text: str) -> str:
if text[-1] != "\n":
if not text.endswith("\n"):
return text + "\n"
else:
return text
Expand Down
14 changes: 14 additions & 0 deletions tests/test_dsl_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,3 +1086,17 @@ def test_can_disable_normalizing_newlines():
suite = parse_test_suite(json_str)
actual_stderr = suite.tabs[0].contexts[0].testcases[0].output.stderr.data
assert actual_stderr == "12"


def test_empty_text_data_newlines():
yaml_str = """
- unit: "Statement and main"
cases:
- script:
- arguments: [ '-a', '5', '7' ]
stderr: ""
"""
json_str = translate_to_test_suite(yaml_str)
suite = parse_test_suite(json_str)
actual_stderr = suite.tabs[0].contexts[0].testcases[0].output.stderr.data
assert actual_stderr == "\n"

0 comments on commit d0906b0

Please sign in to comment.