|
7 | 7 | from json2xml import dicttoxml |
8 | 8 |
|
9 | 9 | if TYPE_CHECKING: |
10 | | - pass |
| 10 | + from _pytest.capture import CaptureFixture |
| 11 | + from _pytest.fixtures import FixtureRequest |
| 12 | + from _pytest.logging import LogCaptureFixture |
| 13 | + from _pytest.monkeypatch import MonkeyPatch |
| 14 | + from pytest_mock.plugin import MockerFixture |
11 | 15 |
|
12 | 16 |
|
13 | 17 | class TestDict2xml: |
@@ -522,7 +526,7 @@ def test_list_to_xml_with_mixed_items(self) -> None: |
522 | 526 |
|
523 | 527 | def test_list_to_xml_with_empty_list(self) -> None: |
524 | 528 | """Test list to XML with empty list.""" |
525 | | - data = {"items": []} |
| 529 | + data: dict[str, list[Any]] = {"items": []} |
526 | 530 | result = dicttoxml.dicttoxml(data, root=False, attr_type=False, item_wrap=True) |
527 | 531 | assert result == b"<items></items>" |
528 | 532 |
|
@@ -574,13 +578,14 @@ class CustomClass: |
574 | 578 | pass |
575 | 579 |
|
576 | 580 | # Should return the class name for unsupported types |
577 | | - result = dicttoxml.get_xml_type(CustomClass()) |
| 581 | + # Using type: ignore for intentional test of unsupported type |
| 582 | + result = dicttoxml.get_xml_type(CustomClass()) # type: ignore[arg-type] |
578 | 583 | assert result == "CustomClass" |
579 | 584 |
|
580 | 585 | def test_make_valid_xml_name_invalid_chars(self) -> None: |
581 | 586 | """Test make_valid_xml_name with invalid XML characters.""" |
582 | 587 | key = "<invalid>key" |
583 | | - attr = {} |
| 588 | + attr: dict[str, Any] = {} |
584 | 589 | new_key, new_attr = dicttoxml.make_valid_xml_name(key, attr) |
585 | 590 | assert new_key == "key" |
586 | 591 | assert new_attr == {"name": "<invalid>key"} |
@@ -781,7 +786,7 @@ def test_get_unique_id_with_duplicates(self) -> None: |
781 | 786 | call_count = 0 |
782 | 787 | original_make_id = module.make_id |
783 | 788 |
|
784 | | - def mock_make_id(element, start=100000, end=999999): |
| 789 | + def mock_make_id(element: str, start: int = 100000, end: int = 999999) -> str: |
785 | 790 | nonlocal call_count |
786 | 791 | call_count += 1 |
787 | 792 | if call_count == 1: |
@@ -870,7 +875,7 @@ class CustomClass: |
870 | 875 |
|
871 | 876 | with pytest.raises(TypeError, match="Unsupported data type:"): |
872 | 877 | dicttoxml.convert( |
873 | | - obj=CustomClass(), |
| 878 | + obj=CustomClass(), # type: ignore[arg-type] |
874 | 879 | ids=None, |
875 | 880 | attr_type=False, |
876 | 881 | item_func=lambda x: "item", |
@@ -1015,7 +1020,7 @@ def test_dict2xml_str_with_primitive_dict_rawitem(self) -> None: |
1015 | 1020 | import json2xml.dicttoxml as module |
1016 | 1021 | original_is_primitive = module.is_primitive_type |
1017 | 1022 |
|
1018 | | - def mock_is_primitive(val): |
| 1023 | + def mock_is_primitive(val: Any) -> bool: |
1019 | 1024 | if isinstance(val, dict) and val == {"test": "data"}: |
1020 | 1025 | return True |
1021 | 1026 | return original_is_primitive(val) |
|
0 commit comments