diff --git a/tested/dsl/translate_parser.py b/tested/dsl/translate_parser.py index 16324483..5bd72bf1 100644 --- a/tested/dsl/translate_parser.py +++ b/tested/dsl/translate_parser.py @@ -90,6 +90,13 @@ class ReturnOracle: ) +def _ensure_trailing_newline(text: str) -> str: + if text[-1] != "\n": + return text + "\n" + else: + return text + + def _parse_yaml_value(loader: yaml.Loader, node: yaml.Node) -> Any: if isinstance(node, yaml.MappingNode): result = loader.construct_mapping(node) @@ -442,7 +449,7 @@ def _convert_testcase(testcase: YamlDict, context: DslContext) -> Testcase: else: if "stdin" in testcase: assert isinstance(testcase["stdin"], str) - stdin = TextData(data=testcase["stdin"]) + stdin = TextData(data=_ensure_trailing_newline(testcase["stdin"])) else: stdin = EmptyChannel.NONE arguments = testcase.get("arguments", []) diff --git a/tests/test_dsl_yaml.py b/tests/test_dsl_yaml.py index 12155eec..6bdc9d31 100644 --- a/tests/test_dsl_yaml.py +++ b/tests/test_dsl_yaml.py @@ -62,7 +62,7 @@ def test_parse_one_tab_ctx(): assert len(context.testcases) == 1 tc = context.testcases[0] assert tc.is_main_testcase() - assert tc.input.stdin.data == "Input string" + assert tc.input.stdin.data == "Input string\n" assert tc.input.arguments == ["--arg", "argument"] assert tc.output.stderr.data == "Error string" assert tc.output.stdout.data == "Output string"