diff options
author | Anthon van der Neut <anthon@mnt.org> | 2018-08-15 16:15:16 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2018-08-15 16:15:16 +0200 |
commit | 21e5474048c6a5b9a267c3717078cd207ee0bdb1 (patch) | |
tree | 99c224edb71ba91941e19e3b13411989b37a5b3a /_test/test_literal.py | |
parent | d89af927856c1f7f24cbc71045ae04e1cd375071 (diff) | |
download | ruamel.yaml-21e5474048c6a5b9a267c3717078cd207ee0bdb1.tar.gz |
oitnb formats all tests
Diffstat (limited to '_test/test_literal.py')
-rw-r--r-- | _test/test_literal.py | 91 |
1 files changed, 56 insertions, 35 deletions
diff --git a/_test/test_literal.py b/_test/test_literal.py index 86ae5f6..edb86ce 100644 --- a/_test/test_literal.py +++ b/_test/test_literal.py @@ -3,7 +3,7 @@ from __future__ import print_function import pytest # NOQA -from roundtrip import YAML +from roundtrip import YAML # does an automatic dedent on load """ @@ -31,31 +31,34 @@ class TestNoIndent: def test_top_literal_scalar_indent_example_9_5(self): yaml = YAML() s = '%!PS-Adobe-2.0' - d = yaml.load(""" + inp = """ --- | {} - """.format(s)) + """ + d = yaml.load(inp.format(s)) print(d) assert d == s + '\n' def test_top_literal_scalar_no_indent(self): yaml = YAML() s = 'testing123' - d = yaml.load(""" + inp = """ --- | {} - """.format(s)) + """ + d = yaml.load(inp.format(s)) print(d) assert d == s + '\n' def test_top_literal_scalar_no_indent_1_1(self): yaml = YAML() s = 'testing123' - d = yaml.load(""" + inp = """ %YAML 1.1 --- | {} - """.format(s)) + """ + d = yaml.load(inp.format(s)) print(d) assert d == s + '\n' @@ -64,11 +67,12 @@ class TestNoIndent: from ruamel.yaml import safe_load s = 'testing123' - d = safe_load(dedent(""" + inp = """ %YAML 1.1 --- | {} - """.format(s))) + """ + d = safe_load(dedent(inp.format(s))) print(d) assert d == s + '\n' @@ -79,80 +83,88 @@ class TestNoIndent: yaml.top_level_block_style_scalar_no_indent_error_1_1 = True s = 'testing123' with pytest.raises(ParserError): - yaml.load(""" + inp = """ %YAML 1.1 --- | {} - """.format(s)) + """ + yaml.load(inp.format(s)) def test_top_literal_scalar_indent_offset_one(self): yaml = YAML() s = 'testing123' - d = yaml.load(""" + inp = """ --- |1 {} - """.format(s)) + """ + d = yaml.load(inp.format(s)) print(d) assert d == s + '\n' def test_top_literal_scalar_indent_offset_four(self): yaml = YAML() s = 'testing123' - d = yaml.load(""" + inp = """ --- |4 {} - """.format(s)) + """ + d = yaml.load(inp.format(s)) print(d) assert d == s + '\n' def test_top_literal_scalar_indent_offset_two_leading_space(self): yaml = YAML() s = ' testing123' - d = yaml.load(""" + inp = """ --- |4 {s} {s} - """.format(s=s)) + """ + d = yaml.load(inp.format(s=s)) print(d) assert d == (s + '\n') * 2 def test_top_literal_scalar_no_indent_special(self): yaml = YAML() s = '%!PS-Adobe-2.0' - d = yaml.load(""" + inp = """ --- | {} - """.format(s)) + """ + d = yaml.load(inp.format(s)) print(d) assert d == s + '\n' def test_top_folding_scalar_indent(self): yaml = YAML() s = '%!PS-Adobe-2.0' - d = yaml.load(""" + inp = """ --- > {} - """.format(s)) + """ + d = yaml.load(inp.format(s)) print(d) assert d == s + '\n' def test_top_folding_scalar_no_indent(self): yaml = YAML() s = 'testing123' - d = yaml.load(""" + inp = """ --- > {} - """.format(s)) + """ + d = yaml.load(inp.format(s)) print(d) assert d == s + '\n' def test_top_folding_scalar_no_indent_special(self): yaml = YAML() s = '%!PS-Adobe-2.0' - d = yaml.load(""" + inp = """ --- > {} - """.format(s)) + """ + d = yaml.load(inp.format(s)) print(d) assert d == s + '\n' @@ -160,12 +172,13 @@ class TestNoIndent: yaml = YAML(typ='safe', pure=True) s1 = 'abc' s2 = 'klm' - for idx, d1 in enumerate(yaml.load_all(""" + inp = """ --- |- {} --- | {} - """.format(s1, s2))): + """ + for idx, d1 in enumerate(yaml.load_all(inp.format(s1, s2))): print('d1:', d1) assert ['abc', 'klm\n'][idx] == d1 @@ -178,7 +191,8 @@ class Test_RoundTripLiteral: ys = """ --- | {} - """.format(s) + """ + ys = ys.format(s) d = yaml.load(ys) yaml.dump(d, compare=ys) @@ -190,7 +204,8 @@ class Test_RoundTripLiteral: ys = """ --- | {} - """.format(s) + """ + ys = ys.format(s) d = yaml.load(ys) yaml.dump(d, compare=ys) @@ -202,7 +217,8 @@ class Test_RoundTripLiteral: ys = """ --- {} - """.format(s) + """ + ys = ys.format(s) d = yaml.load(ys) yaml.dump(d, compare=ys) @@ -214,7 +230,8 @@ class Test_RoundTripLiteral: ys = """ --- {} - """.format(s) + """ + ys = ys.format(s) d = yaml.load(ys) yaml.dump(d, compare=ys) @@ -226,7 +243,8 @@ class Test_RoundTripLiteral: ys = """ --- {} - """.format(s) + """ + ys = ys.format(s) d = yaml.load(ys) yaml.dump(d, compare=ys) @@ -240,7 +258,8 @@ class Test_RoundTripLiteral: ys = """ --- {} - """.format(s) + """ + ys = ys.format(s) d = yaml.load(ys) yaml.dump(d, compare=ys) @@ -251,7 +270,8 @@ class Test_RoundTripLiteral: ys = """ --- |- {} - """.format(s) + """ + ys = ys.format(s) d = yaml.load(ys) yaml.dump(d, compare=ys) @@ -261,6 +281,7 @@ class Test_RoundTripLiteral: ys = """ - | {} - """.format(s) + """ + ys = ys.format(s) d = yaml.load(ys) yaml.dump(d, compare=ys) |