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

Skip to content

Commit 5b8d24a

Browse files
committed
Fix obvious problems from switch to dict views. Some tests still fail over
some reference count issue (I think).
1 parent c7e9d74 commit 5b8d24a

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

Lib/test/test_bsddb.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_iteritems_while_modifying_values(self):
9494
if not hasattr(self.f, 'iteritems'):
9595
return
9696

97-
di = self.d.items()
97+
di = iter(self.d.items())
9898
while 1:
9999
try:
100100
k, v = di.next()
@@ -105,7 +105,7 @@ def test_iteritems_while_modifying_values(self):
105105
# it should behave the same as a dict. modifying values
106106
# of existing keys should not break iteration. (adding
107107
# or removing keys should)
108-
fi = self.f.items()
108+
fi = iter(self.f.items())
109109
while 1:
110110
try:
111111
k, v = fi.next()
@@ -159,7 +159,7 @@ def test__no_deadlock_first(self, debug=0):
159159
# test the iterator interface (if present)
160160
if hasattr(self.f, 'iteritems'):
161161
if debug: print("D")
162-
i = self.f.items()
162+
i = iter(self.f.items())
163163
k,v = i.next()
164164
if debug: print("E")
165165
self.f[k] = "please don't deadlock"
@@ -198,7 +198,7 @@ def test_for_cursor_memleak(self):
198198
# do the bsddb._DBWithCursor _iter_mixin internals leak cursors?
199199
nc1 = len(self.f._cursor_refs)
200200
# create iterator
201-
i = self.f.items()
201+
i = iter(self.f.items())
202202
nc2 = len(self.f._cursor_refs)
203203
# use the iterator (should run to the first yeild, creating the cursor)
204204
k, v = i.next()
@@ -246,8 +246,7 @@ def test_update(self):
246246
def test_keyordering(self):
247247
if self.openmethod[0] is not bsddb.btopen:
248248
return
249-
keys = self.d.keys()
250-
keys.sort()
249+
keys = sorted(self.d.keys())
251250
self.assertEqual(self.f.first()[0], keys[0])
252251
self.assertEqual(self.f.next()[0], keys[1])
253252
self.assertEqual(self.f.last()[0], keys[-1])

0 commit comments

Comments
 (0)