diff --git a/test/cast/main.py b/test/cast/main.py index f947684..6f4bfd4 100644 --- a/test/cast/main.py +++ b/test/cast/main.py @@ -35,9 +35,9 @@ test_data = [ status = 0 for tp, s, guessed_val, cast_val in test_data: try: - slog(INFO, f'guessed type of "{s}" = "{guess_type(s)}", should be "{tp}"') # type: ignore - slog(INFO, f'cast_str("{s}") = "{cast_str(s)}"') # type: ignore - slog(INFO, f'cast_str("{s}, {tp}") = "{cast_str(s, target_type=tp)}"') # type: ignore + slog(INFO, f'guessed type of "{s}" = "{guess_type(s)}", should be "{tp}"') # type: ignore[arg-type] + slog(INFO, f'cast_str("{s}") = "{cast_str(s)}"') # type: ignore[arg-type] + slog(INFO, f'cast_str("{s}, {tp}") = "{cast_str(s, target_type=tp)}"') # type: ignore[arg-type] except Exception as e: if s is None: slog(INFO, f'guessed type of "{s}" = Exception, should be "Exception"') diff --git a/test/parse_opts/test.py b/test/parse_opts/test.py index 6478131..f032cdc 100644 --- a/test/parse_opts/test.py +++ b/test/parse_opts/test.py @@ -1,8 +1,6 @@ from jw.util.log import NOTICE, slog from jw.util.Options import Options -i: str | int - delim = "======================= " d = "----------------------- " @@ -15,8 +13,8 @@ slog(NOTICE, d + "by index") for i in range(0, 4): slog(NOTICE, "attr({}) = {}".format(i, a.get(i, by_index = True, default = False))) slog(NOTICE, d + "by key") -for i in ["this", "that", "b", "a", "doit"]: - slog(NOTICE, "attr({}) = {}".format(i, a[i])) +for k in ["this", "that", "b", "a", "doit"]: + slog(NOTICE, "attr({}) = {}".format(k, a[k])) s = '"me": "too", "Pfalse": true, "myarr": ["a", "b", "c"], "me": "not"' slog(NOTICE, delim + s) @@ -27,8 +25,8 @@ slog(NOTICE, d + "by index") for i in range(0, 5): slog(NOTICE, "attr({}) = {}".format(i, a.get(i, by_index = True, default = False))) slog(NOTICE, d + "by key in keys()") -for i in a.keys(): - slog(NOTICE, "attr({}) = {}".format(i, a[i])) +for k in a.keys(): + slog(NOTICE, "attr({}) = {}".format(k, a[k])) slog(NOTICE, d + "by key") -for i in ["me", "Pfalse", "myarr"]: - slog(NOTICE, "attr({}) = {}".format(i, a[i])) +for k in ["me", "Pfalse", "myarr"]: + slog(NOTICE, "attr({}) = {}".format(k, a[k])) diff --git a/test/unit/python/jw/util/load_yaml/test.py b/test/unit/python/jw/util/load_yaml/test.py index 63666fa..c5ec481 100644 --- a/test/unit/python/jw/util/load_yaml/test.py +++ b/test/unit/python/jw/util/load_yaml/test.py @@ -13,8 +13,11 @@ from jw.util.load_yaml import load_yaml # -- Helpers ------------------------------------------------------------------ +_YamlFile = Callable[[str], str] +_TempDir = Callable[[list[tuple[str, str]]], str] + @pytest.fixture -def yaml_file() -> Callable[[str], str]: +def yaml_file() -> _YamlFile: """Create a temporary YAML file and return its path.""" def _make(content: str) -> str: @@ -27,7 +30,7 @@ def yaml_file() -> Callable[[str], str]: return _make @pytest.fixture -def temp_dir() -> Generator: +def temp_dir() -> Generator[_TempDir, None, None]: """Create a temporary directory with files, return the directory.""" import shutil @@ -51,49 +54,49 @@ def temp_dir() -> Generator: class TestBasicLoading: """Tests for basic YAML file loading without links or includes.""" - def test_simple_dict(self, yaml_file: Callable) -> None: + def test_simple_dict(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('key: value\n')) assert data == {'key': 'value'} - def test_nested_dict(self, yaml_file: Callable) -> None: + def test_nested_dict(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('outer:\n inner: value\n number: 42\n')) assert data == {'outer': {'inner': 'value', 'number': 42}} - def test_list_value(self, yaml_file: Callable) -> None: + def test_list_value(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('items:\n - a\n - b\n - c\n')) assert data == {'items': ['a', 'b', 'c']} - def test_empty_file(self, yaml_file: Callable) -> None: + def test_empty_file(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('')) assert data == {} - def test_none_root(self, yaml_file: Callable) -> None: + def test_none_root(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('---\n')) assert data == {} - def test_string_value(self, yaml_file: Callable) -> None: + def test_string_value(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('key: string value\n')) assert data == {'key': 'string value'} - def test_number_value(self, yaml_file: Callable) -> None: + def test_number_value(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('int: 42\nfloat: 3.14\n')) assert data['int'] == 42 assert data['float'] == 3.14 - def test_boolean_value(self, yaml_file: Callable) -> None: + def test_boolean_value(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('enabled: true\ndisabled: false\n')) assert data['enabled'] is True assert data['disabled'] is False - def test_null_value(self, yaml_file: Callable) -> None: + def test_null_value(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('key: null\n')) assert data['key'] is None - def test_multiline_string(self, yaml_file: Callable) -> None: + def test_multiline_string(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('key: |\n line1\n line2\n')) assert data['key'] == 'line1\nline2\n' - def test_deeply_nested(self, yaml_file: Callable) -> None: + def test_deeply_nested(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('a:\n b:\n c:\n d: deep\n')) assert data == {'a': {'b': {'c': {'d': 'deep'}}}} @@ -110,7 +113,7 @@ class TestOptionalLoading: with pytest.raises(FileNotFoundError): load_yaml('nonexistent_file.yaml', optional = False) - def test_present_optional(self, yaml_file: Callable) -> None: + def test_present_optional(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('key: val\n'), optional = True) assert data == {'key': 'val'} @@ -119,15 +122,15 @@ class TestOptionalLoading: class TestRootTypeCheck: """Tests that non-dict YAML roots are rejected.""" - def test_string_root_raises(self, yaml_file: Callable) -> None: + def test_string_root_raises(self, yaml_file: _YamlFile) -> None: with pytest.raises(TypeError, match = 'root must be a mapping'): load_yaml(yaml_file('"just a string"\n')) - def test_list_root_raises(self, yaml_file: Callable) -> None: + def test_list_root_raises(self, yaml_file: _YamlFile) -> None: with pytest.raises(TypeError, match = 'root must be a mapping'): load_yaml(yaml_file('- item1\n- item2\n')) - def test_number_root_raises(self, yaml_file: Callable) -> None: + def test_number_root_raises(self, yaml_file: _YamlFile) -> None: with pytest.raises(TypeError, match = 'root must be a mapping'): load_yaml(yaml_file('42\n')) @@ -136,7 +139,7 @@ class TestRootTypeCheck: class TestIncludeDirective: """Tests for the include directive.""" - def test_single_include(self, temp_dir: Callable) -> None: + def test_single_include(self, temp_dir: _TempDir) -> None: base = temp_dir( [ ('base.yaml', 'shared: from_base\n'), @@ -147,7 +150,7 @@ class TestIncludeDirective: assert data['shared'] == 'from_base' assert data['current'] == 'here' - def test_multiple_includes(self, temp_dir: Callable) -> None: + def test_multiple_includes(self, temp_dir: _TempDir) -> None: base = temp_dir( [ ('a.yaml', 'from_a: 1\nshared: a\n'), @@ -162,7 +165,7 @@ class TestIncludeDirective: assert data['shared'] == 'b' assert data['local'] is True - def test_optional_include(self, temp_dir: Callable) -> None: + def test_optional_include(self, temp_dir: _TempDir) -> None: base = temp_dir( [ ('main.yaml', 'jw.include:\n - "- nonexist.yaml"\nok: true\n'), @@ -171,7 +174,7 @@ class TestIncludeDirective: data = load_yaml(pathlib.Path(base) / 'main.yaml') assert data == {'ok': True} - def test_deep_merge_dicts(self, temp_dir: Callable) -> None: + def test_deep_merge_dicts(self, temp_dir: _TempDir) -> None: base = temp_dir( [ ('base.yaml', 'config:\n db:\n host: localhost\n port: 5432\n'), @@ -190,7 +193,7 @@ class TestIncludeDirective: assert data['config']['db']['name'] == 'mydb' assert data['config']['cache'] is True - def test_nested_includes(self, temp_dir: Callable) -> None: + def test_nested_includes(self, temp_dir: _TempDir) -> None: base = temp_dir( [ ('level1.yaml', 'from: level1\n'), @@ -201,7 +204,7 @@ class TestIncludeDirective: data = load_yaml(pathlib.Path(base) / 'main.yaml') assert data['from'] == 'level2' - def test_include_circular_detect(self, temp_dir: Callable) -> None: + def test_include_circular_detect(self, temp_dir: _TempDir) -> None: base = temp_dir( [ ('a.yaml', 'jw.include: b.yaml\n'), @@ -211,7 +214,7 @@ class TestIncludeDirective: with pytest.raises(ValueError, match = 'Cyclic YAML include'): load_yaml(pathlib.Path(base) / 'a.yaml') - def test_include_relative_path(self, temp_dir: Callable) -> None: + def test_include_relative_path(self, temp_dir: _TempDir) -> None: base = temp_dir( [ ('sub/inner.yaml', 'secret: found\n'), @@ -226,7 +229,7 @@ class TestIncludeDirective: class TestInplaceLinks: """Tests for inplace jw.link expansion.""" - def test_inplace_absolute(self, yaml_file: Callable) -> None: + def test_inplace_absolute(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file('target:\n key: val\nlink:\n jw.link: target.key\n') ) @@ -234,17 +237,17 @@ class TestInplaceLinks: # Original target should still be there assert data['target']['key'] == 'val' - def test_inplace_dict_target(self, yaml_file: Callable) -> None: + def test_inplace_dict_target(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file('target:\n a: 1\n b: 2\nlink:\n jw.link: target\n') ) assert data['link'] == {'a': 1, 'b': 2} - def test_inplace_list_target(self, yaml_file: Callable) -> None: + def test_inplace_list_target(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('target:\n - x\n - y\nlink:\n jw.link: target\n')) assert data['link'] == ['x', 'y'] - def test_inplace_in_list(self, yaml_file: Callable) -> None: + def test_inplace_in_list(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file( 'target: val\nitems:\n - plain\n - jw.link: target\n - more\n' @@ -252,11 +255,11 @@ class TestInplaceLinks: ) assert data['items'] == ['plain', 'val', 'more'] - def test_inplace_scalar_in_list(self, yaml_file: Callable) -> None: + def test_inplace_scalar_in_list(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('target: 42\nitems:\n - 1\n - jw.link: target\n')) assert data['items'] == [1, 42] - def test_inplace_in_nested_dict(self, yaml_file: Callable) -> None: + def test_inplace_in_nested_dict(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file( 'target: deep\nnested:\n level:\n link:\n jw.link: target\n' @@ -269,23 +272,23 @@ class TestInplaceLinks: class TestNamedLinks: """Tests for named jw.link expansion.""" - def test_named_absolute(self, yaml_file: Callable) -> None: + def test_named_absolute(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file('target:\n key: val\nlink:\n jw.link: name|target.key\n') ) assert data['link'] == {'name': 'val'} - def test_named_dict_target(self, yaml_file: Callable) -> None: + def test_named_dict_target(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('target:\n a: 1\nlink:\n jw.link: alias|target\n')) assert data['link'] == {'alias': {'a': 1}} - def test_named_in_list(self, yaml_file: Callable) -> None: + def test_named_in_list(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file('target: val\nitems:\n - plain\n - jw.link: renamed|target\n') ) assert data['items'] == ['plain', {'renamed': 'val'}] - def test_named_with_dashes_and_underscores(self, yaml_file: Callable) -> None: + def test_named_with_dashes_and_underscores(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('target: ok\nlink:\n jw.link: my-name|target\n')) assert data['link'] == {'my-name': 'ok'} @@ -294,7 +297,7 @@ class TestNamedLinks: class TestRelativePaths: """Tests for relative jw.link paths.""" - def test_relative_up_one(self, yaml_file: Callable) -> None: + def test_relative_up_one(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file( 'parent:\n' @@ -306,13 +309,13 @@ class TestRelativePaths: ) assert data['parent']['child']['link'] == 'value' - def test_relative_up_one_simple(self, yaml_file: Callable) -> None: + def test_relative_up_one_simple(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file('sibling: val\nnode:\n link:\n jw.link: ..sibling\n') ) assert data['node']['link'] == 'val' - def test_relative_up_two(self, yaml_file: Callable) -> None: + def test_relative_up_two(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file( 'root_val: my_root\n' @@ -324,13 +327,13 @@ class TestRelativePaths: ) assert data['level1']['level2']['link'] == 'my_root' - def test_relative_up_two_simple(self, yaml_file: Callable) -> None: + def test_relative_up_two_simple(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file('base_val: my_base\nsub:\n link:\n jw.link: ..base_val\n') ) assert data['sub']['link'] == 'my_base' - def test_relative_up_then_descend(self, yaml_file: Callable) -> None: + def test_relative_up_then_descend(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file( 'shared:\n' @@ -344,27 +347,27 @@ class TestRelativePaths: ) assert data['nested']['a']['b']['link'] == 'found' - def test_relative_up_then_descend_simple(self, yaml_file: Callable) -> None: + def test_relative_up_then_descend_simple(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file('shared:\n value: ok\nnode:\n link:\n jw.link: ..shared\n') ) assert data['node']['link'] == {'value': 'ok'} - def test_relative_same_level(self, yaml_file: Callable) -> None: + def test_relative_same_level(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('a: 1\nb:\n link:\n jw.link: ..a\n')) assert data['b']['link'] == 1 - def test_relative_same_level_simple(self, yaml_file: Callable) -> None: + def test_relative_same_level_simple(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file('sibling: val\nnode:\n link:\n jw.link: ..sibling\n') ) assert data['node']['link'] == 'val' - def test_relative_above_root_raises(self, yaml_file: Callable) -> None: + def test_relative_above_root_raises(self, yaml_file: _YamlFile) -> None: with pytest.raises(ValueError, match = 'above root'): load_yaml(yaml_file('link:\n jw.link: ....above\n')) - def test_relative_deep_nesting(self, yaml_file: Callable) -> None: + def test_relative_deep_nesting(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file( 'shared: value\n' @@ -378,12 +381,12 @@ class TestRelativePaths: ) assert data['depth']['l1']['l2']['l3']['link'] == 'value' - def test_relative_self_same_dict(self, yaml_file: Callable) -> None: + def test_relative_self_same_dict(self, yaml_file: _YamlFile) -> None: # Link pointing to ancestor dict containing itself is a cycle with pytest.raises(ValueError, match = 'Cyclic link'): load_yaml(yaml_file('a:\n x: 1\n b:\n c:\n jw.link: ...a\n')) - def test_relative_up_to_root_then_descend(self, yaml_file: Callable) -> None: + def test_relative_up_to_root_then_descend(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file( 'root_data: ok\na:\n b:\n link:\n jw.link: ...root_data\n' @@ -391,7 +394,7 @@ class TestRelativePaths: ) assert data['a']['b']['link'] == 'ok' - def test_relative_up_from_deep(self, yaml_file: Callable) -> None: + def test_relative_up_from_deep(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file( 'root_val: here\n' @@ -404,11 +407,11 @@ class TestRelativePaths: ) assert data['top']['middle']['bot']['link'] == 'here' - def test_relative_link_to_sibling_dict(self, yaml_file: Callable) -> None: + def test_relative_link_to_sibling_dict(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('a:\n x: 1\nb:\n link:\n jw.link: ..a\n')) assert data['b']['link'] == {'x': 1} - def test_relative_up_two_from_deep(self, yaml_file: Callable) -> None: + def test_relative_up_two_from_deep(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file( 'root_val: here\n' @@ -426,7 +429,7 @@ class TestRelativePaths: class TestTransitiveLinks: """Tests for transitive link resolution.""" - def test_chain_of_links(self, yaml_file: Callable) -> None: + def test_chain_of_links(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file( 'target: final\n' @@ -439,13 +442,13 @@ class TestTransitiveLinks: assert data['link_a'] == 'final' assert data['link_b'] == 'final' - def test_chain_inplace(self, yaml_file: Callable) -> None: + def test_chain_inplace(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file('value: 100\na:\n jw.link: b\nb:\n jw.link: value\n') ) assert data['a'] == 100 - def test_chain_named(self, yaml_file: Callable) -> None: + def test_chain_named(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('value: ok\nlink:\n jw.link: copy|value\n')) assert data['link'] == {'copy': 'ok'} @@ -454,21 +457,21 @@ class TestTransitiveLinks: class TestCycleDetection: """Tests for cycle detection in links.""" - def test_self_referencing_link(self, yaml_file: Callable) -> None: + def test_self_referencing_link(self, yaml_file: _YamlFile) -> None: with pytest.raises(ValueError, match = 'Cyclic link'): load_yaml(yaml_file('link:\n jw.link: link\n')) - def test_mutual_cycle(self, yaml_file: Callable) -> None: + def test_mutual_cycle(self, yaml_file: _YamlFile) -> None: with pytest.raises(ValueError, match = 'Cyclic link'): load_yaml(yaml_file('a:\n jw.link: b\nb:\n jw.link: a\n')) - def test_self_cycle_nested(self, yaml_file: Callable) -> None: + def test_self_cycle_nested(self, yaml_file: _YamlFile) -> None: with pytest.raises(ValueError, match = 'Cyclic link'): load_yaml( yaml_file('root:\n inner:\n link:\n jw.link: root.inner\n') ) - def test_cycle_deep_chain(self, yaml_file: Callable) -> None: + def test_cycle_deep_chain(self, yaml_file: _YamlFile) -> None: with pytest.raises(ValueError, match = 'Cyclic link'): load_yaml( yaml_file('a:\n jw.link: c\nc:\n jw.link: b\nb:\n jw.link: a\n') @@ -479,32 +482,32 @@ class TestCycleDetection: class TestMissingTargets: """Tests for missing link targets.""" - def test_missing_absolute_target(self, yaml_file: Callable) -> None: + def test_missing_absolute_target(self, yaml_file: _YamlFile) -> None: with pytest.raises(ValueError, match = 'cannot resolve target path'): load_yaml(yaml_file('link:\n jw.link: nonexistent\n')) - def test_missing_relative_target(self, yaml_file: Callable) -> None: + def test_missing_relative_target(self, yaml_file: _YamlFile) -> None: with pytest.raises(ValueError, match = 'above root'): load_yaml(yaml_file('link:\n jw.link: ..missing\n')) - def test_missing_deep_target(self, yaml_file: Callable) -> None: + def test_missing_deep_target(self, yaml_file: _YamlFile) -> None: with pytest.raises(ValueError, match = 'cannot resolve target path'): load_yaml( yaml_file('exists:\n val: ok\nlink:\n jw.link: exists.missing\n') ) - def test_missing_relative_deep_target(self, yaml_file: Callable) -> None: + def test_missing_relative_deep_target(self, yaml_file: _YamlFile) -> None: with pytest.raises(ValueError, match = 'cannot resolve target path'): load_yaml( yaml_file('a:\n b: val\nnode:\n link:\n jw.link: ..a.missing\n') ) - def test_missing_target_in_list_raises(self, yaml_file: Callable) -> None: + def test_missing_target_in_list_raises(self, yaml_file: _YamlFile) -> None: """Navigating into a list by key name raises with context.""" with pytest.raises(ValueError, match = 'cannot resolve target path'): load_yaml(yaml_file('items:\n - a\nlink:\n jw.link: items.x\n')) - def test_missing_target_error_names_link(self, yaml_file: Callable) -> None: + def test_missing_target_error_names_link(self, yaml_file: _YamlFile) -> None: """The error message names the failing link and its location.""" with pytest.raises(ValueError, match = "jw.link 'nope' at link"): load_yaml(yaml_file('link:\n jw.link: nope\n')) @@ -514,18 +517,18 @@ class TestMissingTargets: class TestNoLinksRegression: """Ensure data without links passes through unchanged.""" - def test_simple_no_links(self, yaml_file: Callable) -> None: + def test_simple_no_links(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('a: 1\nb:\n c: 2\n')) assert data == {'a': 1, 'b': {'c': 2}} - def test_complex_structure(self, yaml_file: Callable) -> None: + def test_complex_structure(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file('list:\n - a\n - b\nnested:\n deep:\n value: 42\n') ) assert data['list'] == ['a', 'b'] assert data['nested']['deep']['value'] == 42 - def test_jw_link_with_siblings_unchanged(self, yaml_file: Callable) -> None: + def test_jw_link_with_siblings_unchanged(self, yaml_file: _YamlFile) -> None: """jw.link with sibling keys should NOT be expanded.""" data = load_yaml( yaml_file('target: val\nlink:\n jw.link: target\n other: kept\n') @@ -539,7 +542,7 @@ class TestNoLinksRegression: class TestIncludePlusLinks: """Tests combining include directives and link expansion.""" - def test_include_then_link(self, temp_dir: Callable) -> None: + def test_include_then_link(self, temp_dir: _TempDir) -> None: base = temp_dir( [ ('base.yaml', 'shared: from_include\n'), @@ -550,7 +553,7 @@ class TestIncludePlusLinks: assert data['shared'] == 'from_include' assert data['link'] == 'from_include' - def test_link_in_included_file(self, temp_dir: Callable) -> None: + def test_link_in_included_file(self, temp_dir: _TempDir) -> None: base = temp_dir( [ ('base.yaml', 'target: included\ndecorator:\n jw.link: target\n'), @@ -561,7 +564,7 @@ class TestIncludePlusLinks: assert data['target'] == 'included' assert data['decorator'] == 'included' - def test_relative_link_to_included(self, temp_dir: Callable) -> None: + def test_relative_link_to_included(self, temp_dir: _TempDir) -> None: base = temp_dir( [ ('base.yaml', 'base_val: ok\n'), @@ -579,23 +582,23 @@ class TestIncludePlusLinks: class TestEdgeCases: """Tests for edge cases in link expansion.""" - def test_empty_string_value(self, yaml_file: Callable) -> None: + def test_empty_string_value(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('target: ""\nlink:\n jw.link: target\n')) assert data['link'] == '' - def test_zero_value(self, yaml_file: Callable) -> None: + def test_zero_value(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('target: 0\nlink:\n jw.link: target\n')) assert data['link'] == 0 - def test_false_value(self, yaml_file: Callable) -> None: + def test_false_value(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('target: false\nlink:\n jw.link: target\n')) assert data['link'] is False - def test_none_target(self, yaml_file: Callable) -> None: + def test_none_target(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('target: null\nlink:\n jw.link: target\n')) assert data['link'] is None - def test_complex_nested_inplace(self, yaml_file: Callable) -> None: + def test_complex_nested_inplace(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file( 'target:\n' @@ -608,20 +611,20 @@ class TestEdgeCases: ) assert data['link']['deep'] == 'value' - def test_link_to_list_of_dicts(self, yaml_file: Callable) -> None: + def test_link_to_list_of_dicts(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file('target:\n - key: a\n - key: b\nlink:\n jw.link: target\n') ) assert data['link'] == [{'key': 'a'}, {'key': 'b'}] - def test_multiple_links_same_target(self, yaml_file: Callable) -> None: + def test_multiple_links_same_target(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file('target: val\na:\n jw.link: target\nb:\n jw.link: target\n') ) assert data['a'] == 'val' assert data['b'] == 'val' - def test_cached_link_expansion_not_aliased(self, yaml_file: Callable) -> None: + def test_cached_link_expansion_not_aliased(self, yaml_file: _YamlFile) -> None: """Link results shared via the memoisation cache are independent.""" data = load_yaml( yaml_file( @@ -637,27 +640,27 @@ class TestEdgeCases: assert data['link_b']['x'] == 1 assert data['target']['x'] == 1 - def test_named_link_to_list(self, yaml_file: Callable) -> None: + def test_named_link_to_list(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file('target:\n - x\n - y\nlink:\n jw.link: items|target\n') ) assert data['link'] == {'items': ['x', 'y']} - def test_link_value_with_pipe_in_target_key(self, yaml_file: Callable) -> None: + def test_link_value_with_pipe_in_target_key(self, yaml_file: _YamlFile) -> None: """Key with pipe in name — pipe triggers named link parsing.""" with pytest.raises(ValueError, match = 'cannot resolve target path'): load_yaml(yaml_file('my|key: val\nlink:\n jw.link: my|key\n')) - def test_named_link_with_numeric_prefix(self, yaml_file: Callable) -> None: + def test_named_link_with_numeric_prefix(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('target: ok\nlink:\n jw.link: 123target|target\n')) assert data['link'] == {'123target': 'ok'} - def test_non_string_link_value_raises(self, yaml_file: Callable) -> None: + def test_non_string_link_value_raises(self, yaml_file: _YamlFile) -> None: """Non-string jw.link values raise TypeError naming the value.""" with pytest.raises(TypeError, match = 'must be a string'): load_yaml(yaml_file('target: 42\nlink:\n jw.link: 42\n')) - def test_non_string_inplace_link_value_raises(self, yaml_file: Callable) -> None: + def test_non_string_inplace_link_value_raises(self, yaml_file: _YamlFile) -> None: """Non-string jw.inplace-link values raise TypeError.""" with pytest.raises(TypeError, match = 'must be a string'): load_yaml(yaml_file('target:\n a: 1\nentry:\n jw.inplace-link: 42\n')) @@ -667,12 +670,12 @@ class TestEdgeCases: class TestInplaceLink: """Tests for jw.inplace-link expansion with sibling merging.""" - def test_inplace_link_no_siblings(self, yaml_file: Callable) -> None: + def test_inplace_link_no_siblings(self, yaml_file: _YamlFile) -> None: """jw.inplace-link alone replaces the value (like jw.link).""" data = load_yaml(yaml_file('target: val\nlink:\n jw.inplace-link: target\n')) assert data['link'] == 'val' - def test_inplace_link_with_dict_siblings(self, yaml_file: Callable) -> None: + def test_inplace_link_with_dict_siblings(self, yaml_file: _YamlFile) -> None: """jw.inplace-link with sibling keys deep-merges into resolved dict.""" data = load_yaml( yaml_file( @@ -690,7 +693,7 @@ class TestInplaceLink: assert data['entry']['b'] == 'overridden' assert data['entry']['c'] == 3 - def test_inplace_link_with_scalar_sibling(self, yaml_file: Callable) -> None: + def test_inplace_link_with_scalar_sibling(self, yaml_file: _YamlFile) -> None: """Scalar siblings merge into resolved dict.""" data = load_yaml( yaml_file( @@ -704,13 +707,13 @@ class TestInplaceLink: assert data['entry']['nested'] == 'dict' assert data['entry']['flag'] is True - def test_inplace_link_non_dict_target(self, yaml_file: Callable) -> None: + def test_inplace_link_non_dict_target(self, yaml_file: _YamlFile) -> None: """Non-dict target without siblings replaces the value.""" data = load_yaml(yaml_file('target: val\nentry:\n jw.inplace-link: target\n')) assert data['entry'] == 'val' def test_inplace_link_non_dict_target_siblings_raise( - self, yaml_file: Callable + self, yaml_file: _YamlFile ) -> None: """Non-dict target with sibling keys raises instead of dropping them.""" with pytest.raises(ValueError, match = 'not a mapping'): @@ -720,7 +723,9 @@ class TestInplaceLink: ) ) - def test_inplace_link_list_target_siblings_raise(self, yaml_file: Callable) -> None: + def test_inplace_link_list_target_siblings_raise( + self, yaml_file: _YamlFile + ) -> None: """List target with sibling keys raises instead of dropping them.""" with pytest.raises(ValueError, match = 'not a mapping'): load_yaml( @@ -729,7 +734,7 @@ class TestInplaceLink: ) ) - def test_inplace_link_relative_path(self, yaml_file: Callable) -> None: + def test_inplace_link_relative_path(self, yaml_file: _YamlFile) -> None: """jw.inplace-link supports relative paths.""" data = load_yaml( yaml_file( @@ -744,12 +749,12 @@ class TestInplaceLink: assert data['root']['entry']['x'] == 'resolved' assert data['root']['entry']['y'] == 'extra' - def test_inplace_link_cyclic(self, yaml_file: Callable) -> None: + def test_inplace_link_cyclic(self, yaml_file: _YamlFile) -> None: """jw.inplace-link detects cycles.""" with pytest.raises(ValueError, match = 'Cyclic link'): load_yaml(yaml_file('a:\n jw.inplace-link: b\nb:\n jw.inplace-link: a\n')) - def test_inplace_link_chain(self, yaml_file: Callable) -> None: + def test_inplace_link_chain(self, yaml_file: _YamlFile) -> None: """jw.inplace-link resolves through transitive chains.""" data = load_yaml( yaml_file( @@ -762,7 +767,7 @@ class TestInplaceLink: ) assert data['a'] == 'final' - def test_inplace_link_with_list_sibling(self, yaml_file: Callable) -> None: + def test_inplace_link_with_list_sibling(self, yaml_file: _YamlFile) -> None: """List sibling values merge into resolved dict.""" data = load_yaml( yaml_file( @@ -778,7 +783,7 @@ class TestInplaceLink: assert data['entry']['key'] == 'val' assert data['entry']['items'] == ['a', 'b'] - def test_inplace_link_in_list(self, yaml_file: Callable) -> None: + def test_inplace_link_in_list(self, yaml_file: _YamlFile) -> None: """jw.inplace-link works inside list items.""" data = load_yaml( yaml_file( @@ -793,7 +798,7 @@ class TestInplaceLink: assert data['items'][0] == {'x': 1, 'y': 2} assert data['items'][1] == 'plain' - def test_inplace_link_deep_nesting(self, yaml_file: Callable) -> None: + def test_inplace_link_deep_nesting(self, yaml_file: _YamlFile) -> None: """jw.inplace-link merges deeply nested dicts.""" data = load_yaml( yaml_file( @@ -813,7 +818,7 @@ class TestInplaceLink: assert data['entry']['a']['b']['d'] == 'added' assert data['entry']['a']['e'] == 'new' - def test_inplace_link_override_deep(self, yaml_file: Callable) -> None: + def test_inplace_link_override_deep(self, yaml_file: _YamlFile) -> None: """Sibling values override target values in deep merge.""" data = load_yaml( yaml_file( @@ -828,7 +833,7 @@ class TestInplaceLink: ) assert data['entry']['a']['b'] == 'overridden' - def test_inplace_link_with_include(self, temp_dir: Callable) -> None: + def test_inplace_link_with_include(self, temp_dir: _TempDir) -> None: """jw.inplace-link works with included files.""" base = temp_dir( [ @@ -844,7 +849,7 @@ class TestInplaceLink: assert data['entry']['from'] == 'include' assert data['entry']['local'] == 'here' - def test_inplace_link_transitive_relative(self, yaml_file: Callable) -> None: + def test_inplace_link_transitive_relative(self, yaml_file: _YamlFile) -> None: """jw.inplace-link with relative paths resolves through chain. Target A's relative link '.chat-janware-com' should resolve from @@ -872,7 +877,7 @@ class TestInplaceLink: class TestIncludeWithPath: """Tests for jw.include with target path specification.""" - def test_include_at_root(self, temp_dir: Callable) -> None: + def test_include_at_root(self, temp_dir: _TempDir) -> None: """Plain include merges at root (original behavior).""" base = temp_dir( [ @@ -883,7 +888,7 @@ class TestIncludeWithPath: data = load_yaml(pathlib.Path(base) / 'main.yaml') assert data['shared'] == 'from_base' - def test_include_at_nested_path(self, temp_dir: Callable) -> None: + def test_include_at_nested_path(self, temp_dir: _TempDir) -> None: """Include with path merges at the specified location.""" base = temp_dir( [ @@ -894,7 +899,7 @@ class TestIncludeWithPath: data = load_yaml(pathlib.Path(base) / 'main.yaml') assert data['entry']['nested'] == 'value' - def test_include_at_deep_path(self, temp_dir: Callable) -> None: + def test_include_at_deep_path(self, temp_dir: _TempDir) -> None: """Include at deep nested path creates intermediate dicts.""" base = temp_dir( [ @@ -905,7 +910,7 @@ class TestIncludeWithPath: data = load_yaml(pathlib.Path(base) / 'main.yaml') assert data['a']['b']['c']['deep'] == 'nested' - def test_include_merge_with_existing(self, temp_dir: Callable) -> None: + def test_include_merge_with_existing(self, temp_dir: _TempDir) -> None: """Include merges with existing content at target path.""" base = temp_dir( [ @@ -920,7 +925,7 @@ class TestIncludeWithPath: assert data['entry']['existing'] == 'here' assert data['entry']['from_include'] == 'included' - def test_include_override_existing(self, temp_dir: Callable) -> None: + def test_include_override_existing(self, temp_dir: _TempDir) -> None: """Local content at target path overrides included content.""" base = temp_dir( [ @@ -935,7 +940,7 @@ class TestIncludeWithPath: # Local content (original) wins over included (from_include) assert data['entry']['existing'] == 'original' - def test_include_non_dict_intermediate_raises(self, temp_dir: Callable) -> None: + def test_include_non_dict_intermediate_raises(self, temp_dir: _TempDir) -> None: """Including through an existing non-dict value raises.""" base = temp_dir( [ @@ -946,7 +951,7 @@ class TestIncludeWithPath: with pytest.raises(ValueError, match = 'not a mapping'): load_yaml(pathlib.Path(base) / 'main.yaml') - def test_include_non_dict_leaf_raises(self, temp_dir: Callable) -> None: + def test_include_non_dict_leaf_raises(self, temp_dir: _TempDir) -> None: """Including at an existing non-dict leaf raises.""" base = temp_dir( [ @@ -960,7 +965,7 @@ class TestIncludeWithPath: with pytest.raises(ValueError, match = 'not a mapping'): load_yaml(pathlib.Path(base) / 'main.yaml') - def test_multiple_includes_different_paths(self, temp_dir: Callable) -> None: + def test_multiple_includes_different_paths(self, temp_dir: _TempDir) -> None: """Multiple includes can target different paths.""" base = temp_dir( [ @@ -977,7 +982,7 @@ class TestIncludeWithPath: assert data['section1']['a'] == 1 assert data['section2']['b'] == 2 - def test_include_with_optional(self, temp_dir: Callable) -> None: + def test_include_with_optional(self, temp_dir: _TempDir) -> None: """Optional includes with path work correctly.""" base = temp_dir( [ @@ -988,7 +993,7 @@ class TestIncludeWithPath: data = load_yaml(pathlib.Path(base) / 'main.yaml') assert data['section']['opt'] == 'val' - def test_optional_include_missing_target(self, temp_dir: Callable) -> None: + def test_optional_include_missing_target(self, temp_dir: _TempDir) -> None: """A missing optional include at a target path creates no key.""" base = temp_dir( [ @@ -998,7 +1003,7 @@ class TestIncludeWithPath: data = load_yaml(pathlib.Path(base) / 'main.yaml') assert data == {'local': True} - def test_optional_include_missing_existing_target(self, temp_dir: Callable) -> None: + def test_optional_include_missing_existing_target(self, temp_dir: _TempDir) -> None: """A missing optional include leaves an existing target untouched.""" base = temp_dir( [ @@ -1011,7 +1016,7 @@ class TestIncludeWithPath: data = load_yaml(pathlib.Path(base) / 'main.yaml') assert data == {'section': {'kept': True}} - def test_include_pipe_in_filename(self, temp_dir: Callable) -> None: + def test_include_pipe_in_filename(self, temp_dir: _TempDir) -> None: """The first pipe separates target and file, pipes stay in the file.""" base = temp_dir( [ @@ -1022,7 +1027,7 @@ class TestIncludeWithPath: data = load_yaml(pathlib.Path(base) / 'main.yaml') assert data['section']['pip'] == 'ed' - def test_include_plain_and_path_mixed(self, temp_dir: Callable) -> None: + def test_include_plain_and_path_mixed(self, temp_dir: _TempDir) -> None: """Mix plain and path-based includes in same document.""" base = temp_dir( [ @@ -1044,7 +1049,7 @@ class TestIncludeWithPath: class TestIncludeGlobbing: """Tests for glob support in jw.include file specs.""" - def test_glob_multiple_files(self, temp_dir: Callable) -> None: + def test_glob_multiple_files(self, temp_dir: _TempDir) -> None: """All glob matches are included.""" base = temp_dir( [ @@ -1057,7 +1062,7 @@ class TestIncludeGlobbing: assert data['from_a'] == 1 assert data['from_b'] == 2 - def test_glob_lexical_order(self, temp_dir: Callable) -> None: + def test_glob_lexical_order(self, temp_dir: _TempDir) -> None: """Matches are included in lexical order, later files win.""" base = temp_dir( [ @@ -1072,7 +1077,7 @@ class TestIncludeGlobbing: assert data['order'] == 'second' assert data['shared'] == 'two' - def test_glob_char_class(self, temp_dir: Callable) -> None: + def test_glob_char_class(self, temp_dir: _TempDir) -> None: """Character classes match like other glob syntax.""" base = temp_dir( [ @@ -1087,7 +1092,7 @@ class TestIncludeGlobbing: assert data['two'] == 2 assert 'three' not in data - def test_glob_question_mark(self, temp_dir: Callable) -> None: + def test_glob_question_mark(self, temp_dir: _TempDir) -> None: """A question mark matches exactly one character.""" base = temp_dir( [ @@ -1100,19 +1105,19 @@ class TestIncludeGlobbing: assert data['one'] == 1 assert 'twelve' not in data - def test_glob_no_match_raises(self, temp_dir: Callable) -> None: + def test_glob_no_match_raises(self, temp_dir: _TempDir) -> None: """A non-optional glob matching no files raises.""" base = temp_dir([('main.yaml', 'jw.include: missing/*.yaml\n')]) with pytest.raises(ValueError, match = 'matches no files'): load_yaml(pathlib.Path(base) / 'main.yaml') - def test_glob_optional_no_match(self, temp_dir: Callable) -> None: + def test_glob_optional_no_match(self, temp_dir: _TempDir) -> None: """An optional glob matching no files contributes nothing.""" base = temp_dir([('main.yaml', 'jw.include: -missing/*.yaml\n')]) data = load_yaml(pathlib.Path(base) / 'main.yaml') assert data == {} - def test_glob_with_target_path(self, temp_dir: Callable) -> None: + def test_glob_with_target_path(self, temp_dir: _TempDir) -> None: """Each match is merged at the target path, in lexical order.""" base = temp_dir( [ @@ -1128,7 +1133,7 @@ class TestIncludeGlobbing: assert data['section']['shared'] == 'from_a' assert data['section']['extra'] == 'b' - def test_glob_absolute_path(self, temp_dir: Callable) -> None: + def test_glob_absolute_path(self, temp_dir: _TempDir) -> None: """Absolute glob paths work, not just relative ones.""" base = temp_dir( [ @@ -1142,7 +1147,7 @@ class TestIncludeGlobbing: assert data['from_a'] == 1 assert data['from_b'] == 2 - def test_glob_self_include_raises(self, temp_dir: Callable) -> None: + def test_glob_self_include_raises(self, temp_dir: _TempDir) -> None: """A glob matching the including file itself is a cycle.""" base = temp_dir([('main.yaml', 'jw.include: "*.yaml"\n')]) with pytest.raises(ValueError, match = 'Cyclic YAML include'): @@ -1153,15 +1158,15 @@ class TestIncludeGlobbing: class TestPathResolution: """Tests for path resolution logic.""" - def test_absolute_single_key(self, yaml_file: Callable) -> None: + def test_absolute_single_key(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('key: val\nlink:\n jw.link: key\n')) assert data['link'] == 'val' - def test_absolute_multi_level(self, yaml_file: Callable) -> None: + def test_absolute_multi_level(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('a:\n b:\n c: deep\nlink:\n jw.link: a.b.c\n')) assert data['link'] == 'deep' - def test_relative_from_list_index(self, yaml_file: Callable) -> None: + def test_relative_from_list_index(self, yaml_file: _YamlFile) -> None: """Links inside list items should resolve correctly.""" data = load_yaml( yaml_file( @@ -1170,7 +1175,7 @@ class TestPathResolution: ) assert data['items'][1] == 'val' - def test_link_to_nested_value(self, yaml_file: Callable) -> None: + def test_link_to_nested_value(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file( 'a:\n nested:\n deep: value\nlink:\n jw.link: a.nested.deep\n' @@ -1183,34 +1188,34 @@ class TestPathResolution: class TestTypePreservation: """Ensure linked values preserve their original types.""" - def test_string_preserved(self, yaml_file: Callable) -> None: + def test_string_preserved(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('target: "42"\nlink:\n jw.link: target\n')) assert isinstance(data['link'], str) assert data['link'] == '42' - def test_int_preserved(self, yaml_file: Callable) -> None: + def test_int_preserved(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('target: 42\nlink:\n jw.link: target\n')) assert isinstance(data['link'], int) assert data['link'] == 42 - def test_float_preserved(self, yaml_file: Callable) -> None: + def test_float_preserved(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('target: 3.14\nlink:\n jw.link: target\n')) assert isinstance(data['link'], float) assert data['link'] == pytest.approx(3.14) - def test_bool_preserved(self, yaml_file: Callable) -> None: + def test_bool_preserved(self, yaml_file: _YamlFile) -> None: data = load_yaml(yaml_file('target: true\nlink:\n jw.link: target\n')) assert isinstance(data['link'], bool) assert data['link'] is True - def test_list_preserved(self, yaml_file: Callable) -> None: + def test_list_preserved(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file('target:\n - 1\n - 2\n - 3\nlink:\n jw.link: target\n') ) assert isinstance(data['link'], list) assert data['link'] == [1, 2, 3] - def test_nested_types_preserved(self, yaml_file: Callable) -> None: + def test_nested_types_preserved(self, yaml_file: _YamlFile) -> None: data = load_yaml( yaml_file( 'target:\n - num: 1\n flag: true\nlink:\n jw.link: target\n' diff --git a/test/unit/python/jw/util/stree/StringTree/test.py b/test/unit/python/jw/util/stree/StringTree/test.py index 1f651a4..5980cab 100644 --- a/test/unit/python/jw/util/stree/StringTree/test.py +++ b/test/unit/python/jw/util/stree/StringTree/test.py @@ -6,8 +6,10 @@ import pytest from jw.util.stree.StringTree import StringTree +_St = Callable[[str], StringTree] + @pytest.fixture -def st() -> Callable[[str], StringTree]: +def st() -> _St: """Helper that creates a StringTree from raw config text.""" def _load(text: str) -> StringTree: @@ -48,7 +50,7 @@ def st() -> Callable[[str], StringTree]: ('[section]\nkey = [bracket]\n', '[bracket]'), ] ) -def test_value(st, input: str, expected: str) -> None: +def test_value(st: _St, input: str, expected: str) -> None: tree = st(input) assert tree.value('section.key') == expected @@ -61,48 +63,48 @@ def test_value(st, input: str, expected: str) -> None: ('nonexistent.key'), # missing section entirely ] ) -def test_missing_returns_none(st, path: str) -> None: +def test_missing_returns_none(st: _St, path: str) -> None: """Both missing key and missing section return None (no default needed).""" tree = st('[section]\nkey = val\n') assert tree.value(path) is None -def test_missing_key_with_default_none(st) -> None: +def test_missing_key_with_default_none(st: _St) -> None: """value(section.missing, default=None) returns None.""" tree = st('[section]\nother = val\n') assert tree.value('section.missing', default = None) is None -def test_missing_section_with_default_none(st) -> None: +def test_missing_section_with_default_none(st: _St) -> None: """value(nonexistent.key, default=None) returns None.""" tree = st('[section]\nkey = val\n') assert tree.value('nonexistent.key', default = None) is None # -- Multiple keys and sections ----------------------------------------------- -def test_multiple_keys(st) -> None: +def test_multiple_keys(st: _St) -> None: tree = st('[section]\nfirst = one\nsecond = two\nthird = three\n') assert tree.value('section.first') == 'one' assert tree.value('section.second') == 'two' assert tree.value('section.third') == 'three' -def test_multiple_sections(st) -> None: +def test_multiple_sections(st: _St) -> None: tree = st('[one]\nkey = val1\n[two]\nkey = val2\n') assert tree.value('one.key') == 'val1' assert tree.value('two.key') == 'val2' # -- Edge cases --------------------------------------------------------------- -def test_not_an_assignment_returns_none(st) -> None: +def test_not_an_assignment_returns_none(st: _St) -> None: tree = st('[section]\nnot an assignment\n') assert tree.value('section.not an assignment') is None -def test_empty_key_raises(st) -> None: +def test_empty_key_raises(st: _St) -> None: """Empty key raises StringTree.Error during parsing.""" with pytest.raises(StringTree.Error): st('[section]\n= value\n') # -- Missing section (no-op, originally had no assertion) --------------------- -def test_missing_section_noop(st) -> None: +def test_missing_section_noop(st: _St) -> None: """Previously this test called value() without asserting anything; add an explicit check so the test is meaningful.""" tree = st('[section]\nkey = val\n') @@ -111,13 +113,13 @@ def test_missing_section_noop(st) -> None: # -- Line continuation (Not yet implemented) ---------------------------------- # # @pytest.mark.skip(reason="Line continuation not yet implemented") -# def test_line_continuation(st): +# def test_line_continuation(st: _St): # tree = st('[section]\nkey = first \\\n second \\\n third\n') # assert tree.value('section.key') == 'first second third' # # # @pytest.mark.skip(reason="Line continuation not yet implemented") -# def test_line_continuation_with_comment(st): +# def test_line_continuation_with_comment(st: _St): # tree = st('[section]\nkey = first \\\n second # comment\n') # assert tree.value('section.key') == 'first second' #