From 6b9cb54872e7fc0519e896bedea5a96386d4ee08 Mon Sep 17 00:00:00 2001 From: wurstsalat Date: Fri, 9 Dec 2022 22:10:14 +0100 Subject: cq: Move remove_invalid_xml_chars method and add test --- test/no_gui/test_text_helpers.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/no_gui/test_text_helpers.py b/test/no_gui/test_text_helpers.py index c71b8ee8e..bdff8f317 100644 --- a/test/no_gui/test_text_helpers.py +++ b/test/no_gui/test_text_helpers.py @@ -3,9 +3,23 @@ import unittest from gajim.common.text_helpers import escape_iri_path_segment from gajim.common.text_helpers import jid_to_iri from gajim.common.text_helpers import format_duration +from gajim.common.text_helpers import remove_invalid_xml_chars class Test(unittest.TestCase): + + def test_remove_invalid_xml_chars(self) -> None: + invalid_chars = [ + '\x0b', + '\udfff', + '\x08' + ] + for char in invalid_chars: + self.assertEqual(remove_invalid_xml_chars(char), '') + + self.assertEqual(remove_invalid_xml_chars(''), '') + self.assertEqual(remove_invalid_xml_chars('ä'), 'ä') + def test_escape_iri_path_segment(self): self.assertEqual(escape_iri_path_segment(''), '', '') -- cgit v1.2.3