diff options
Diffstat (limited to '_test/test_version.py')
-rw-r--r-- | _test/test_version.py | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/_test/test_version.py b/_test/test_version.py index 0855a5c..9aa4133 100644 --- a/_test/test_version.py +++ b/_test/test_version.py @@ -1,18 +1,20 @@ # coding: utf-8 -import pytest # NOQA +import pytest # NOQA from roundtrip import dedent, round_trip, round_trip_load def load(s, version=None): import ruamel.yaml # NOQA + return ruamel.yaml.round_trip_load(dedent(s), version) class TestVersions: def test_explicit_1_2(self): - r = load("""\ + r = load( + """\ %YAML 1.2 --- - 12:34:56 @@ -24,7 +26,8 @@ class TestVersions: - yes - no - true - """) + """ + ) assert r[0] == '12:34:56' assert r[1] == 12 assert r[2] == 12345678 @@ -36,7 +39,8 @@ class TestVersions: assert r[8] is True def test_explicit_1_1(self): - r = load("""\ + r = load( + """\ %YAML 1.1 --- - 12:34:56 @@ -48,7 +52,8 @@ class TestVersions: - yes - no - true - """) + """ + ) assert r[0] == 45296 assert r[1] == 10 assert r[2] == '012345678' @@ -60,7 +65,8 @@ class TestVersions: assert r[8] is True def test_implicit_1_2(self): - r = load("""\ + r = load( + """\ - 12:34:56 - 12:34:56.78 - 012 @@ -71,7 +77,8 @@ class TestVersions: - yes - no - true - """) + """ + ) assert r[0] == '12:34:56' assert r[1] == '12:34:56.78' assert r[2] == 12 @@ -84,7 +91,8 @@ class TestVersions: assert r[9] is True def test_load_version_1_1(self): - r = load("""\ + r = load( + """\ - 12:34:56 - 12:34:56.78 - 012 @@ -95,7 +103,9 @@ class TestVersions: - yes - no - true - """, version="1.1") + """, + version='1.1', + ) assert r[0] == 45296 assert r[1] == 45296.78 assert r[2] == 10 @@ -112,7 +122,9 @@ class TestIssue62: # bitbucket issue 62, issue_62 def test_00(self): import ruamel.yaml # NOQA - s = dedent("""\ + + s = dedent( + """\ {}# Outside flow collection: - ::vector - ": - ()" @@ -121,14 +133,17 @@ class TestIssue62: - http://example.com/foo#bar # Inside flow collection: - [::vector, ": - ()", "Down, down and away!", -456, http://example.com/foo#bar] - """) + """ + ) with pytest.raises(ruamel.yaml.parser.ParserError): round_trip(s.format('%YAML 1.1\n---\n'), preserve_quotes=True) - round_trip(s.format(''), preserve_quotes=True) + round_trip(s.format(""), preserve_quotes=True) def test_00_single_comment(self): import ruamel.yaml # NOQA - s = dedent("""\ + + s = dedent( + """\ {}# Outside flow collection: - ::vector - ": - ()" @@ -136,22 +151,26 @@ class TestIssue62: - -123 - http://example.com/foo#bar - [::vector, ": - ()", "Down, down and away!", -456, http://example.com/foo#bar] - """) + """ + ) with pytest.raises(ruamel.yaml.parser.ParserError): round_trip(s.format('%YAML 1.1\n---\n'), preserve_quotes=True) - round_trip(s.format(''), preserve_quotes=True) + round_trip(s.format(""), preserve_quotes=True) # round_trip(s.format('%YAML 1.2\n---\n'), preserve_quotes=True, version=(1, 2)) def test_01(self): import ruamel.yaml # NOQA - s = dedent("""\ + + s = dedent( + """\ {}[random plain value that contains a ? character] - """) + """ + ) with pytest.raises(ruamel.yaml.parser.ParserError): round_trip(s.format('%YAML 1.1\n---\n'), preserve_quotes=True) - round_trip(s.format(''), preserve_quotes=True) + round_trip(s.format(""), preserve_quotes=True) # note the flow seq on the --- line! - round_trip(s.format('%YAML 1.2\n--- '), preserve_quotes=True, version="1.2") + round_trip(s.format('%YAML 1.2\n--- '), preserve_quotes=True, version='1.2') def test_so_45681626(self): # was not properly parsing |