Remove lxml deprecated methods

All our supported runtimes [1] are compatible with the recommended
alternatives.

The `getchildren` method is deprecated [2] since lxml 2.0 and will be removed
in future versions, these changes switch usages to `list(elem)` as
recommended in the official documentation [2].

[1] https://governance.openstack.org/tc/reference/runtimes/victoria.html#python-runtimes-for-train
[2] https://lxml.de/api/lxml.etree._Element-class.html#getchildren

Change-Id: I5264edb93532d90703ae7b59cd71520a2cd3518a
This commit is contained in:
Hervé Beraud 2020-06-23 11:31:32 +02:00
parent a47d5a1152
commit e91a3d73ad
3 changed files with 4 additions and 4 deletions

View File

@ -92,7 +92,7 @@ def tostring(tree, use_s3ns=True, xml_declaration=True):
root = Element(tree.tag, attrib=tree.attrib, nsmap=nsmap) root = Element(tree.tag, attrib=tree.attrib, nsmap=nsmap)
root.text = tree.text root.text = tree.text
root.extend(deepcopy(tree.getchildren())) root.extend(deepcopy(list(tree)))
tree = root tree = root
return lxml.etree.tostring(tree, xml_declaration=xml_declaration, return lxml.etree.tostring(tree, xml_declaration=xml_declaration,

View File

@ -58,7 +58,7 @@ class TestS3ApiVersioning(S3ApiBase):
'GET', 'bucket', query='versioning') 'GET', 'bucket', query='versioning')
self.assertEqual(status, 200) self.assertEqual(status, 200)
elem = fromstring(body) elem = fromstring(body)
self.assertEqual(elem.getchildren(), []) self.assertEqual(list(elem), [])
# Enable versioning # Enable versioning
elem = Element('VersioningConfiguration') elem = Element('VersioningConfiguration')
@ -108,7 +108,7 @@ class TestS3ApiVersioning(S3ApiBase):
'GET', 'bucket', query='versioning') 'GET', 'bucket', query='versioning')
self.assertEqual(status, 200) self.assertEqual(status, 200)
elem = fromstring(body) elem = fromstring(body)
self.assertEqual(elem.getchildren(), []) self.assertEqual(list(elem), [])
# Suspend versioning # Suspend versioning
elem = Element('VersioningConfiguration') elem = Element('VersioningConfiguration')

View File

@ -42,7 +42,7 @@ class TestS3ApiVersioning(S3ApiTestCase):
status, headers, body = self._versioning_GET(path) status, headers, body = self._versioning_GET(path)
self.assertEqual(status.split()[0], '200') self.assertEqual(status.split()[0], '200')
elem = fromstring(body, 'VersioningConfiguration') elem = fromstring(body, 'VersioningConfiguration')
self.assertEqual(elem.getchildren(), []) self.assertEqual(list(elem), [])
def _versioning_GET_enabled(self, path): def _versioning_GET_enabled(self, path):
self.swift.register('HEAD', '/v1/AUTH_test/bucket', HTTPNoContent, { self.swift.register('HEAD', '/v1/AUTH_test/bucket', HTTPNoContent, {