Skip to content

Commit

Permalink
IMPROVEMENT: more defusexml fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amilcarlucas committed Jun 17, 2024
1 parent cf230ee commit e446fc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 1 addition & 2 deletions MethodicConfigurator/annotate_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
from sys import exit as sys_exit
from typing import Any, Dict, List, Optional, Tuple

from xml.etree import ElementTree as ET # no parsing, just data-structure manipulation

import argparse
import logging

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


Expand Down
10 changes: 6 additions & 4 deletions unittests/annotate_params_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
from unittest.mock import patch, mock_open
import os
import unittest
import xml.etree.ElementTree as ET
import requests
import mock

from annotate_params import get_xml_data
from xml.etree import ElementTree as ET # no parsing, just data-structure manipulation
from defusedxml import ElementTree as DET # just parsing, no data-structure manipulation

from MethodicConfigurator.annotate_params import get_xml_data
from MethodicConfigurator.annotate_params import remove_prefix
from MethodicConfigurator.annotate_params import split_into_lines
from MethodicConfigurator.annotate_params import create_doc_dict
Expand Down Expand Up @@ -258,7 +260,7 @@ def test_create_doc_dict(self):
</param>
</root>
'''
root = ET.fromstring(xml_data)
root = DET.fromstring(xml_data)

# Expected output
expected_output = {
Expand Down Expand Up @@ -491,7 +493,7 @@ def test_print_read_only_params(self, mock_info):
</param>
</root>
'''
root = ET.fromstring(xml_data)
root = DET.fromstring(xml_data)
doc_dict = create_doc_dict(root, "VehicleType")

# Call the function with the mock XML data
Expand Down

0 comments on commit e446fc3

Please sign in to comment.