FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.11] gh-100933: Improve `check_element` helper in `test_xml_etree` (GH-100934) by miss-islington · Pull Request #101686 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
27 changes: 4 additions & 23 deletions Lib/test/test_xml_etree.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -203,25 +203,6 @@ def serialize_check(self, elem, expected):
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)
Expand All @@ -231,12 +212,12 @@ def check_element(element):
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)

Expand Down

Back | FazBrowse Home | New Git URL