diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-02-08 10:13:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-08 10:13:43 (GMT) |
commit | eb49d32b9af0b3b01a5588626179187f11d145c9 (patch) | |
tree | b5036d0321c0d9ab18de5c848031f2a04625d1e5 /Lib/test/test_xml_etree.py | |
parent | feec49c40736fc05626a183a8d14c4ebbea5ae28 (diff) | |
download | cpython-eb49d32b9af0b3b01a5588626179187f11d145c9.zip cpython-eb49d32b9af0b3b01a5588626179187f11d145c9.tar.gz cpython-eb49d32b9af0b3b01a5588626179187f11d145c9.tar.bz2 |
gh-100933: Improve `check_element` helper in `test_xml_etree` (#100934)
Items checked by this test are always `str` and `dict` instances.
Diffstat (limited to 'Lib/test/test_xml_etree.py')
-rw-r--r-- | Lib/test/test_xml_etree.py | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index ca5bb56..11efee0 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -203,25 +203,6 @@ class ElementTreeTest(unittest.TestCase): def test_interface(self): # Test element tree interface. - def check_string(string): - len(string) - for char in string: - self.assertEqual(len(char), 1, - msg="expected one-character string, got %r" % char) - new_string = string + "" - new_string = string + " " - string[:0] - - def check_mapping(mapping): - len(mapping) - keys = mapping.keys() - items = mapping.items() - for key in keys: - item = mapping[key] - mapping["key"] = "value" - self.assertEqual(mapping["key"], "value", - msg="expected value string, got %r" % mapping["key"]) - def check_element(element): self.assertTrue(ET.iselement(element), msg="not an element") direlem = dir(element) @@ -231,12 +212,12 @@ class ElementTreeTest(unittest.TestCase): self.assertIn(attr, direlem, msg='no %s visible by dir' % attr) - check_string(element.tag) - check_mapping(element.attrib) + self.assertIsInstance(element.tag, str) + self.assertIsInstance(element.attrib, dict) if element.text is not None: - check_string(element.text) + self.assertIsInstance(element.text, str) if element.tail is not None: - check_string(element.tail) + self.assertIsInstance(element.tail, str) for elem in element: check_element(elem) |