Skip to content

Commit 9564a83

Browse files
committed
fix: consolidate module imports to avoid mixed import styles
Move 'import json2xml.dicttoxml_fast as fast_module' to top level and remove duplicate local imports inside test methods.
1 parent eee477b commit 9564a83

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

tests/test_rust_dicttoxml.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
except ImportError:
1717
RUST_AVAILABLE = False
1818

19+
import json2xml.dicttoxml_fast as fast_module
1920
from json2xml import dicttoxml as py_dicttoxml
2021
from json2xml.dicttoxml_fast import (
2122
dicttoxml as fast_dicttoxml,
@@ -573,8 +574,6 @@ def test_escape_xml_python_fallback(self):
573574
"""Test escape_xml falls back to Python when Rust unavailable."""
574575
from unittest.mock import patch
575576

576-
import json2xml.dicttoxml_fast as fast_module
577-
578577
# Temporarily mock _USE_RUST to False
579578
with patch.object(fast_module, '_USE_RUST', False):
580579
result = fast_module.escape_xml("Hello <World>")
@@ -585,8 +584,6 @@ def test_wrap_cdata_python_fallback(self):
585584
"""Test wrap_cdata falls back to Python when Rust unavailable."""
586585
from unittest.mock import patch
587586

588-
import json2xml.dicttoxml_fast as fast_module
589-
590587
# Temporarily mock _USE_RUST to False
591588
with patch.object(fast_module, '_USE_RUST', False):
592589
result = fast_module.wrap_cdata("Hello World")
@@ -596,8 +593,6 @@ def test_escape_xml_fallback_when_rust_func_none(self):
596593
"""Test escape_xml falls back when rust_escape_xml is None."""
597594
from unittest.mock import patch
598595

599-
import json2xml.dicttoxml_fast as fast_module
600-
601596
with patch.object(fast_module, 'rust_escape_xml', None):
602597
result = fast_module.escape_xml("Test & Value")
603598
assert "&amp;" in result
@@ -606,8 +601,6 @@ def test_wrap_cdata_fallback_when_rust_func_none(self):
606601
"""Test wrap_cdata falls back when rust_wrap_cdata is None."""
607602
from unittest.mock import patch
608603

609-
import json2xml.dicttoxml_fast as fast_module
610-
611604
with patch.object(fast_module, 'rust_wrap_cdata', None):
612605
result = fast_module.wrap_cdata("Test Content")
613606
assert result == "<![CDATA[Test Content]]>"

0 commit comments

Comments
 (0)