Skip to content

Commit e446fc3

Browse files
committed
IMPROVEMENT: more defusexml fixes
1 parent cf230ee commit e446fc3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

MethodicConfigurator/annotate_params.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@
3131
from sys import exit as sys_exit
3232
from typing import Any, Dict, List, Optional, Tuple
3333

34-
from xml.etree import ElementTree as ET # no parsing, just data-structure manipulation
35-
3634
import argparse
3735
import logging
3836

37+
from xml.etree import ElementTree as ET # no parsing, just data-structure manipulation
3938
from defusedxml import ElementTree as DET # just parsing, no data-structure manipulation
4039

4140

unittests/annotate_params_test.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
from unittest.mock import patch, mock_open
1515
import os
1616
import unittest
17-
import xml.etree.ElementTree as ET
1817
import requests
1918
import mock
2019

21-
from annotate_params import get_xml_data
20+
from xml.etree import ElementTree as ET # no parsing, just data-structure manipulation
21+
from defusedxml import ElementTree as DET # just parsing, no data-structure manipulation
22+
23+
from MethodicConfigurator.annotate_params import get_xml_data
2224
from MethodicConfigurator.annotate_params import remove_prefix
2325
from MethodicConfigurator.annotate_params import split_into_lines
2426
from MethodicConfigurator.annotate_params import create_doc_dict
@@ -258,7 +260,7 @@ def test_create_doc_dict(self):
258260
</param>
259261
</root>
260262
'''
261-
root = ET.fromstring(xml_data)
263+
root = DET.fromstring(xml_data)
262264

263265
# Expected output
264266
expected_output = {
@@ -491,7 +493,7 @@ def test_print_read_only_params(self, mock_info):
491493
</param>
492494
</root>
493495
'''
494-
root = ET.fromstring(xml_data)
496+
root = DET.fromstring(xml_data)
495497
doc_dict = create_doc_dict(root, "VehicleType")
496498

497499
# Call the function with the mock XML data

0 commit comments

Comments
 (0)