Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 091153d

Browse files
committed
Make test_sax pass.
1 parent 87b6395 commit 091153d

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

Lib/test/test_sax.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,11 @@ def test_expat_nsattrs_wattr():
358358
(attrs.getQNames() == [] or attrs.getQNames() == ["ns:attr"]) and \
359359
len(attrs) == 1 and \
360360
(ns_uri, "attr") in attrs and \
361-
attrs.keys() == [(ns_uri, "attr")] and \
361+
list(attrs.keys()) == [(ns_uri, "attr")] and \
362362
attrs.get((ns_uri, "attr")) == "val" and \
363363
attrs.get((ns_uri, "attr"), 25) == "val" and \
364-
attrs.items() == [((ns_uri, "attr"), "val")] and \
365-
attrs.values() == ["val"] and \
364+
list(attrs.items()) == [((ns_uri, "attr"), "val")] and \
365+
list(attrs.values()) == ["val"] and \
366366
attrs.getValue((ns_uri, "attr")) == "val" and \
367367
attrs[(ns_uri, "attr")] == "val"
368368

@@ -698,7 +698,7 @@ def test_sf_1511497():
698698
# Bug report: http://www.python.org/sf/1511497
699699
import sys
700700
old_modules = sys.modules.copy()
701-
for modname in sys.modules.keys():
701+
for modname in list(sys.modules.keys()):
702702
if modname.startswith("xml."):
703703
del sys.modules[modname]
704704
try:
@@ -734,8 +734,7 @@ def make_test_output():
734734
outf.write(result.getvalue())
735735
outf.close()
736736

737-
items = locals().items()
738-
items.sort()
737+
items = sorted(locals().items())
739738
for (name, value) in items:
740739
if name[ : 5] == "test_":
741740
confirm(value(), name)

Lib/xml/sax/xmlreader.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,10 @@ def getQNameByName(self, name):
304304
return name
305305

306306
def getNames(self):
307-
return self._attrs.keys()
307+
return list(self._attrs.keys())
308308

309309
def getQNames(self):
310-
return self._attrs.keys()
310+
return list(self._attrs.keys())
311311

312312
def __len__(self):
313313
return len(self._attrs)
@@ -316,7 +316,7 @@ def __getitem__(self, name):
316316
return self._attrs[name]
317317

318318
def keys(self):
319-
return self._attrs.keys()
319+
return list(self._attrs.keys())
320320

321321
def __contains__(self, name):
322322
return name in self._attrs
@@ -328,10 +328,10 @@ def copy(self):
328328
return self.__class__(self._attrs)
329329

330330
def items(self):
331-
return self._attrs.items()
331+
return list(self._attrs.items())
332332

333333
def values(self):
334-
return self._attrs.values()
334+
return list(self._attrs.values())
335335

336336
# ===== ATTRIBUTESNSIMPL =====
337337

@@ -363,7 +363,7 @@ def getQNameByName(self, name):
363363
return self._qnames[name]
364364

365365
def getQNames(self):
366-
return self._qnames.values()
366+
return list(self._qnames.values())
367367

368368
def copy(self):
369369
return self.__class__(self._attrs, self._qnames)

0 commit comments

Comments
 (0)