Commit 704673e9 authored by Jim Fulton's avatar Jim Fulton

Fixed to use dictionary keys consistently.

Fixed to use a separate Random instance.
parent 8f11181d
...@@ -1618,7 +1618,7 @@ class BugFixes(TestCase): ...@@ -1618,7 +1618,7 @@ class BugFixes(TestCase):
t = OOBTree() t = OOBTree()
random.seed('OOBTree') trandom = random.Random('OOBTree')
global LP294788_ids global LP294788_ids
...@@ -1626,22 +1626,22 @@ class BugFixes(TestCase): ...@@ -1626,22 +1626,22 @@ class BugFixes(TestCase):
LP294788_ids = {} LP294788_ids = {}
ids = {} ids = {}
for i in xrange(1024): for i in xrange(1024):
if random.random() > 0.1: if trandom.random() > 0.1:
#add #add
id = None id = None
while id is None or id in ids: while id is None or id in ids:
id = random.randint(0,1000000) id = trandom.randint(0,1000000)
ids[id] = 1 ids[id] = 1
t[id] = ToBeDeleted(id) t[id] = ToBeDeleted(id)
else: else:
#del #del
id = random.choice(ids.keys()) id = trandom.choice(ids.keys())
del t[id] del t[id]
del ids[id] del ids[id]
ids = ids.keys() ids = ids.keys()
random.shuffle(ids) trandom.shuffle(ids)
for id in ids: for id in ids:
del t[id] del t[id]
ids = None ids = None
...@@ -1659,22 +1659,22 @@ class BugFixes(TestCase): ...@@ -1659,22 +1659,22 @@ class BugFixes(TestCase):
LP294788_ids = {} LP294788_ids = {}
ids = {} ids = {}
for i in xrange(1024): for i in xrange(1024):
if random.random() > 0.1: if trandom.random() > 0.1:
#add #add
id = None id = None
while id is None or id in ids: while id is None or id in ids:
id = random.randint(0,1000000) id = trandom.randint(0,1000000)
ids[id] = 1 ids[id] = 1
t[id] = (id, ToBeDeleted(id), u'somename') t[id] = (id, ToBeDeleted(id), u'somename')
else: else:
#del #del
id = random.choice(ids.keys()) id = trandom.choice(ids.keys())
del t[id] del t[id]
del ids[id] del ids[id]
ids = ids.keys() ids = ids.keys()
random.shuffle(ids) trandom.shuffle(ids)
for id in ids: for id in ids:
del t[id] del t[id]
ids = None ids = None
...@@ -1694,23 +1694,22 @@ class BugFixes(TestCase): ...@@ -1694,23 +1694,22 @@ class BugFixes(TestCase):
LP294788_ids = {} LP294788_ids = {}
ids = {} ids = {}
for i in xrange(1024): for i in xrange(1024):
if random.random() > 0.1: if trandom.random() > 0.1:
#add #add
id = None id = None
while id is None or id in ids: while id is None or id in ids:
id = random.randint(0,1000000) id = ToBeDeleted(trandom.randint(0,1000000))
obj = ToBeDeleted(id) ids[id] = 1
ids[obj] = 1 t[id] = 1
t[obj] = 1
else: else:
#del #del
obj = random.choice(ids.keys()) id = trandom.choice(ids.keys())
del ids[obj] del ids[id]
del t[obj] del t[id]
ids = ids.keys() ids = ids.keys()
random.shuffle(ids) trandom.shuffle(ids)
for id in ids: for id in ids:
del t[id] del t[id]
#release all refs #release all refs
...@@ -1729,23 +1728,23 @@ class BugFixes(TestCase): ...@@ -1729,23 +1728,23 @@ class BugFixes(TestCase):
LP294788_ids = {} LP294788_ids = {}
ids = {} ids = {}
for i in xrange(1024): for i in xrange(1024):
if random.random() > 0.1: if trandom.random() > 0.1:
#add #add
id = None id = None
while id is None or id in ids: while id is None or id in ids:
id = random.randint(0,1000000) id = trandom.randint(0,1000000)
id = (id, ToBeDeleted(id), u'somename')
key = (id, ToBeDeleted(id), u'somename') ids[id] = 1
ids[key] = 1 t[id] = 1
t[key] = 1
else: else:
#del #del
key = random.choice(ids.keys()) id = trandom.choice(ids.keys())
del ids[key] del ids[id]
del t[key] del t[id]
ids = ids.keys() ids = ids.keys()
random.shuffle(ids) trandom.shuffle(ids)
for id in ids: for id in ids:
del t[id] del t[id]
#release all refs #release all refs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment