summaryrefslogtreecommitdiff
path: root/_test/test_string.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2018-08-05 17:05:06 +0200
committerAnthon van der Neut <anthon@mnt.org>2018-08-05 17:05:06 +0200
commite58ed78b291889578477741fb5ad5f05bf914d6b (patch)
tree73fa7be33210f4e9ee033f662486643e041dfdd0 /_test/test_string.py
parent992aecee297f7fe781eddc715fff6d7f5bbed875 (diff)
downloadruamel.yaml-e58ed78b291889578477741fb5ad5f05bf914d6b.tar.gz
undid miswrapping of tests
Diffstat (limited to '_test/test_string.py')
-rw-r--r--_test/test_string.py97
1 files changed, 30 insertions, 67 deletions
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)