From e58ed78b291889578477741fb5ad5f05bf914d6b Mon Sep 17 00:00:00 2001 From: Anthon van der Neut Date: Sun, 5 Aug 2018 17:05:06 +0200 Subject: undid miswrapping of tests --- _test/test_string.py | 97 ++++++++++++++++------------------------------------ 1 file changed, 30 insertions(+), 67 deletions(-) (limited to '_test/test_string.py') diff --git a/_test/test_string.py b/_test/test_string.py index 351ca0e..5a466db 100644 --- a/_test/test_string.py +++ b/_test/test_string.py @@ -24,31 +24,24 @@ from roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NO class TestPreservedScalarString: def test_basic_string(self): - round_trip( - """ + round_trip(""" a: abcdefg - """ - ) + """, ) def test_quoted_integer_string(self): - round_trip( - """ + round_trip(""" a: '12345' - """ - ) + """) @pytest.mark.skipif( platform.python_implementation() == 'Jython', reason='Jython throws RepresenterError' ) def test_preserve_string(self): - round_trip( - """ + round_trip(""" a: | abc def - """, - intermediate=dict(a='abc\ndef\n'), - ) + """, intermediate=dict(a='abc\ndef\n')) @pytest.mark.skipif( platform.python_implementation() == 'Jython', reason='Jython throws RepresenterError' @@ -66,18 +59,15 @@ class TestPreservedScalarString: platform.python_implementation() == 'Jython', reason='Jython throws RepresenterError' ) def test_preserve_string_keep(self): - # with pytest.raises(AssertionError) as excinfo: - round_trip( - """ + # with pytest.raises(AssertionError) as excinfo: + round_trip(""" a: |+ ghi jkl b: x - """, - intermediate=dict(a='ghi\njkl\n\n\n', b='x'), - ) + """, intermediate=dict(a='ghi\njkl\n\n\n', b='x')) @pytest.mark.skipif( platform.python_implementation() == 'Jython', reason='Jython throws RepresenterError' @@ -85,80 +75,59 @@ class TestPreservedScalarString: def test_preserve_string_keep_at_end(self): # at EOF you have to specify the ... to get proper "closure" # of the multiline scalar - round_trip( - """ + round_trip(""" a: |+ ghi jkl ... - """, - intermediate=dict(a='ghi\njkl\n\n'), - ) + """, intermediate=dict(a='ghi\njkl\n\n')) def test_fold_string(self): with pytest.raises(AssertionError) as excinfo: # NOQA - round_trip( - """ + round_trip(""" a: > abc def - """, - intermediate=dict(a='abc def\n'), - ) + """, intermediate=dict(a='abc def\n')) def test_fold_string_strip(self): with pytest.raises(AssertionError) as excinfo: # NOQA - round_trip( - """ + round_trip(""" a: >- abc def - """, - intermediate=dict(a='abc def'), - ) + """, intermediate=dict(a='abc def')) def test_fold_string_keep(self): with pytest.raises(AssertionError) as excinfo: # NOQA - round_trip( - """ + round_trip(""" a: >+ abc def - """, - intermediate=dict(a='abc def\n\n'), - ) + """, intermediate=dict(a='abc def\n\n')) class TestQuotedScalarString: def test_single_quoted_string(self): - round_trip( - """ + round_trip(""" a: 'abc' - """, - preserve_quotes=True, - ) + """, preserve_quotes=True) def test_double_quoted_string(self): - round_trip( - """ + round_trip(""" a: "abc" - """, - preserve_quotes=True, - ) + """, preserve_quotes=True) def test_non_preserved_double_quoted_string(self): - round_trip( - """ + round_trip(""" a: "abc" - """, - outp=""" + """, outp=""" a: abc - """, - ) + """) class TestReplace: @@ -167,35 +136,29 @@ class TestReplace: def test_replace_preserved_scalar_string(self): import ruamel - s = dedent( - """\ + s = dedent("""\ foo: | foo foo bar foo - """ - ) + """) data = round_trip_load(s, preserve_quotes=True) so = data['foo'].replace('foo', 'bar', 2) assert isinstance(so, ruamel.yaml.scalarstring.PreservedScalarString) - assert so == dedent( - """ + assert so == dedent(""" bar bar bar foo - """ - ) + """) def test_replace_double_quoted_scalar_string(self): import ruamel - s = dedent( - """\ + s = dedent("""\ foo: "foo foo bar foo" - """ - ) + """) data = round_trip_load(s, preserve_quotes=True) so = data['foo'].replace('foo', 'bar', 2) assert isinstance(so, ruamel.yaml.scalarstring.DoubleQuotedScalarString) -- cgit v1.2.1