test: Make gen-threads work with python3

python3 doesn't allow dictionaries to be initialized with non-string
keywords. This presents problems on systems in which "python" means
"python3". We instead initalize the dictionary using the dict
comprehension and then update it with the values from the tree. This
will work with both python2 and python3.
This commit is contained in:
Jesse Rosenthal 2014-10-31 13:33:25 -04:00 committed by David Bremner
parent 207f3bf821
commit 0d40b37954

View file

@ -2,7 +2,6 @@
# argv[1]. Each output line is a thread structure, where the n'th # argv[1]. Each output line is a thread structure, where the n'th
# field is either a number giving the parent of message n or "None" # field is either a number giving the parent of message n or "None"
# for the root. # for the root.
import sys import sys
from itertools import chain, combinations from itertools import chain, combinations
@ -28,6 +27,7 @@ while queue:
else: else:
# Expand node to_expand[0] with each possible set of children # Expand node to_expand[0] with each possible set of children
for children in subsets(free): for children in subsets(free):
ntree = dict(tree, **{child: to_expand[0] for child in children}) ntree = {child: to_expand[0] for child in children}
ntree.update(tree)
nfree = free.difference(children) nfree = free.difference(children)
queue.append((ntree, nfree, to_expand[1:] + tuple(children))) queue.append((ntree, nfree, to_expand[1:] + tuple(children)))