From ebf84d8dc84e2c49e96346876a31aead50952184 Mon Sep 17 00:00:00 2001 From: Niko Strijbol Date: Wed, 21 Feb 2024 13:48:48 +0100 Subject: [PATCH] Do not add newlines to empty strings --- tested/dsl/translate_parser.py | 2 +- tests/test_dsl_yaml.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tested/dsl/translate_parser.py b/tested/dsl/translate_parser.py index 47afceb2..2ee33e8d 100644 --- a/tested/dsl/translate_parser.py +++ b/tested/dsl/translate_parser.py @@ -91,7 +91,7 @@ class ReturnOracle: def _ensure_trailing_newline(text: str) -> str: - if not text.endswith("\n"): + if text and not text.endswith("\n"): return text + "\n" else: return text diff --git a/tests/test_dsl_yaml.py b/tests/test_dsl_yaml.py index cb1f682b..b6f2e1a3 100644 --- a/tests/test_dsl_yaml.py +++ b/tests/test_dsl_yaml.py @@ -1099,4 +1099,4 @@ def test_empty_text_data_newlines(): 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" + assert actual_stderr == ""