diff options
Diffstat (limited to '_test/test_indentation.py')
-rw-r--r-- | _test/test_indentation.py | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/_test/test_indentation.py b/_test/test_indentation.py index 6e0fce2..1f16cb2 100644 --- a/_test/test_indentation.py +++ b/_test/test_indentation.py @@ -1,23 +1,24 @@ # coding: utf-8 -import pytest # NOQA +from typing import Any +import pytest # type: ignore # NOQA from roundtrip import round_trip, round_trip_load, round_trip_dump, dedent, YAML -def rt(s): - +def rt(s: str) -> str: res = round_trip_dump(round_trip_load(s)) + assert res is not None return res.strip() + '\n' class TestIndent: - def test_roundtrip_inline_list(self): + def test_roundtrip_inline_list(self) -> None: s = 'a: [a, b, c]\n' output = rt(s) assert s == output - def test_roundtrip_mapping_of_inline_lists(self): + def test_roundtrip_mapping_of_inline_lists(self) -> None: s = dedent("""\ a: [a, b, c] j: [k, l, m] @@ -25,7 +26,7 @@ class TestIndent: output = rt(s) assert s == output - def test_roundtrip_mapping_of_inline_lists_comments(self): + def test_roundtrip_mapping_of_inline_lists_comments(self) -> None: s = dedent("""\ # comment A a: [a, b, c] @@ -35,7 +36,7 @@ class TestIndent: output = rt(s) assert s == output - def test_roundtrip_mapping_of_inline_sequence_eol_comments(self): + def test_roundtrip_mapping_of_inline_sequence_eol_comments(self) -> None: s = dedent("""\ # comment A a: [a, b, c] # comment B @@ -45,7 +46,7 @@ class TestIndent: assert s == output # first test by explicitly setting flow style - def test_added_inline_list(self): + def test_added_inline_list(self) -> None: s1 = dedent(""" a: - b @@ -62,7 +63,7 @@ class TestIndent: # ############ flow mappings - def test_roundtrip_flow_mapping(self): + def test_roundtrip_flow_mapping(self) -> None: s = dedent("""\ - {a: 1, b: hallo} - {j: fka, k: 42} @@ -71,7 +72,7 @@ class TestIndent: output = round_trip_dump(data) assert s == output - def test_roundtrip_sequence_of_inline_mappings_eol_comments(self): + def test_roundtrip_sequence_of_inline_mappings_eol_comments(self) -> None: s = dedent("""\ # comment A - {a: 1, b: hallo} # comment B @@ -80,14 +81,14 @@ class TestIndent: output = rt(s) assert s == output - def test_indent_top_level(self): + def test_indent_top_level(self) -> None: inp = """ - a: - b """ round_trip(inp, indent=4) - def test_set_indent_5_block_list_indent_1(self): + def test_set_indent_5_block_list_indent_1(self) -> None: inp = """ a: - b: c @@ -97,7 +98,7 @@ class TestIndent: """ round_trip(inp, indent=5, block_seq_indent=1) - def test_set_indent_4_block_list_indent_2(self): + def test_set_indent_4_block_list_indent_2(self) -> None: inp = """ a: - b: c @@ -107,7 +108,7 @@ class TestIndent: """ round_trip(inp, indent=4, block_seq_indent=2) - def test_set_indent_3_block_list_indent_0(self): + def test_set_indent_3_block_list_indent_0(self) -> None: inp = """ a: - b: c @@ -117,7 +118,7 @@ class TestIndent: """ round_trip(inp, indent=3, block_seq_indent=0) - def Xtest_set_indent_3_block_list_indent_2(self): + def Xtest_set_indent_3_block_list_indent_2(self) -> None: inp = """ a: - @@ -131,7 +132,7 @@ class TestIndent: """ round_trip(inp, indent=3, block_seq_indent=2) - def test_set_indent_3_block_list_indent_2(self): + def test_set_indent_3_block_list_indent_2(self) -> None: inp = """ a: - b: c @@ -141,7 +142,7 @@ class TestIndent: """ round_trip(inp, indent=3, block_seq_indent=2) - def Xtest_set_indent_2_block_list_indent_2(self): + def Xtest_set_indent_2_block_list_indent_2(self) -> None: inp = """ a: - @@ -156,7 +157,7 @@ class TestIndent: round_trip(inp, indent=2, block_seq_indent=2) # this is how it should be: block_seq_indent stretches the indent - def test_set_indent_2_block_list_indent_2(self): + def test_set_indent_2_block_list_indent_2(self) -> None: inp = """ a: - b: c @@ -167,7 +168,7 @@ class TestIndent: round_trip(inp, indent=2, block_seq_indent=2) # have to set indent! - def test_roundtrip_four_space_indents(self): + def test_roundtrip_four_space_indents(self) -> None: # fmt: off s = ( 'a:\n' @@ -177,7 +178,7 @@ class TestIndent: # fmt: on round_trip(s, indent=4) - def test_roundtrip_four_space_indents_no_fail(self): + def test_roundtrip_four_space_indents_no_fail(self) -> None: inp = """ a: - foo @@ -192,7 +193,7 @@ class TestIndent: class TestYpkgIndent: - def test_00(self): + def test_00(self) -> None: inp = """ name : nano version : 2.3.2 @@ -214,7 +215,7 @@ class TestYpkgIndent: ) -def guess(s): +def guess(s: str) -> Any: from ruamel.yaml.util import load_yaml_guess_indent x, y, z = load_yaml_guess_indent(dedent(s)) @@ -222,21 +223,21 @@ def guess(s): class TestGuessIndent: - def test_guess_20(self): + def test_guess_20(self) -> None: inp = """\ a: - 1 """ assert guess(inp) == (2, 0) - def test_guess_42(self): + def test_guess_42(self) -> None: inp = """\ a: - 1 """ assert guess(inp) == (4, 2) - def test_guess_42a(self): + def test_guess_42a(self) -> None: # block seq indent prevails over nested key indent level inp = """\ b: @@ -245,7 +246,7 @@ class TestGuessIndent: """ assert guess(inp) == (4, 2) - def test_guess_3None(self): + def test_guess_3None(self) -> None: inp = """\ b: a: 1 @@ -256,7 +257,7 @@ class TestGuessIndent: class TestSeparateMapSeqIndents: # using uncommon 6 indent with 3 push in as 2 push in automatically # gets you 4 indent even if not set - def test_00(self): + def test_00(self) -> None: # old style yaml = YAML() yaml.indent = 6 @@ -268,7 +269,7 @@ class TestSeparateMapSeqIndents: """ yaml.round_trip(inp) - def test_01(self): + def test_01(self) -> None: yaml = YAML() yaml.indent(sequence=6) yaml.indent(offset=3) @@ -279,7 +280,7 @@ class TestSeparateMapSeqIndents: """ yaml.round_trip(inp) - def test_02(self): + def test_02(self) -> None: yaml = YAML() yaml.indent(mapping=5, sequence=6, offset=3) inp = """ @@ -290,7 +291,7 @@ class TestSeparateMapSeqIndents: """ yaml.round_trip(inp) - def test_03(self): + def test_03(self) -> None: inp = """ a: b: @@ -300,7 +301,7 @@ class TestSeparateMapSeqIndents: """ round_trip(inp, indent=4) - def test_04(self): + def test_04(self) -> None: yaml = YAML() yaml.indent(mapping=5, sequence=6) inp = """ @@ -312,7 +313,7 @@ class TestSeparateMapSeqIndents: """ yaml.round_trip(inp) - def test_issue_51(self): + def test_issue_51(self) -> None: yaml = YAML() # yaml.map_indent = 2 # the default yaml.indent(sequence=4, offset=2) |