From 7ecc3b7b7e1ea705623663b1ace113ea1aebd33a Mon Sep 17 00:00:00 2001 From: Laurent Bovet Date: Sat, 11 Sep 2021 19:30:03 +0200 Subject: [PATCH] fix text block dump, fixes #10 --- .gitignore | 1 + src/yglu/loader.py | 2 +- tests/samples/strings.yml | 13 +++++++++++++ tests/test_builder.py | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/samples/strings.yml diff --git a/.gitignore b/.gitignore index 19d4b9b..0fe421f 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ MANIFEST # Per-project virtualenvs .venv*/ .conda*/ +dist diff --git a/src/yglu/loader.py b/src/yglu/loader.py index 258d59b..f601fd8 100644 --- a/src/yglu/loader.py +++ b/src/yglu/loader.py @@ -46,7 +46,7 @@ def construct_scalar(self, node): ) if node.style == "|" and isinstance(node.value, str): - ret_val = PreservedScalarString(node.value) + ret_val = SimpleString(node.value) elif bool(self._preserve_quotes) and isinstance(node.value, str): if node.style == "'": ret_val = SingleQuotedScalarString(node.value) diff --git a/tests/samples/strings.yml b/tests/samples/strings.yml new file mode 100644 index 0000000..e460753 --- /dev/null +++ b/tests/samples/strings.yml @@ -0,0 +1,13 @@ +# input +a: hello +b: 'foo:' +c: "!bar" +d: |- + hello + world +--- + +a: hello +b: 'foo:' +c: "!bar" +d: "hello\nworld" \ No newline at end of file diff --git a/tests/test_builder.py b/tests/test_builder.py index 443a8b4..11ed221 100644 --- a/tests/test_builder.py +++ b/tests/test_builder.py @@ -19,6 +19,7 @@ def test_no_tags(): assert data["key2"] == "item2" assert data["list"][1] == 2 assert data["key4"]["key5"] == "item5" + assert "item6" in data["key4"]["key6"] def test_invisible():