Skip to content

Commit 18ce10c

Browse files
committed
test: add breaking tests
1 parent bf6363d commit 18ce10c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_json2xml.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
)
2121

2222

23+
2324
class TestJson2xml:
2425
"""Tests for `json2xml` package."""
2526

@@ -229,3 +230,26 @@ def test_encoding_without_pretty_print(self) -> None:
229230
xmldata = json2xml.Json2xml(data, pretty=False).to_xml()
230231
if xmldata:
231232
assert b'encoding="UTF-8"' in xmldata
233+
234+
def test_escapes_angle_brackets(self):
235+
json_data = json.dumps({"root": {"@attrs": {"HelpText": "version <here>"}}})
236+
result = json2xml.Json2xml(json_data).to_xml()
237+
assert 'HelpText="version &lt;here&gt;"' in result
238+
239+
def test_escapes_quotes(self):
240+
json_data = json.dumps({"root": {"@attrs": {"Text": "\"quoted\""}}})
241+
result = json2xml.Json2xml(json_data).to_xml()
242+
assert 'Text="&quot;quoted&quot;"' in result
243+
244+
def test_escapes_ampersands(self):
245+
json_data = json.dumps({"root": {"@attrs": {"Text": "this & that"}}})
246+
result = json2xml.Json2xml(json_data).to_xml()
247+
assert 'Text="this &amp; that"' in result
248+
249+
def test_escapes_mixed_special_chars(self):
250+
json_data = json.dumps({"root": {"@attrs": {"Text": "<tag> & \"quote\""}}})
251+
result = json2xml.Json2xml(json_data).to_xml()
252+
assert 'Text="&lt;tag&gt; &amp; &quot;quote&quot;"' in result
253+
254+
255+

0 commit comments

Comments
 (0)