# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1238850761 -7200 # Node ID aeb46e43138dd3f3546aa972ec0e9909091ad25a # Parent 9c081452efc29009e90a45bf5f995988308abcfe fix choose_term monkey-patching diff -r 9c081452efc2 -r aeb46e43138d devtools/repotest.py --- a/devtools/repotest.py Sat Apr 04 14:54:04 2009 +0200 +++ b/devtools/repotest.py Sat Apr 04 15:12:41 2009 +0200 @@ -72,7 +72,7 @@ def __contains__(self, key): return key in self.iterkeys() def __getitem__(self, key): - for key_, value in self.iteritems(): + for key_, value in list.__iter__(self): if key == key_: return value raise KeyError(key) @@ -80,6 +80,17 @@ return (x for x, y in list.__iter__(self)) def iteritems(self): return (x for x in list.__iter__(self)) + def items(self): + return [x for x in list.__iter__(self)] + +class DumbOrderedDict2(object): + def __init__(self, origdict, sortkey): + self.origdict = origdict + self.sortkey = sortkey + def __getattr__(self, attr): + return getattr(self.origdict, attr) + def __iter__(self): + return iter(sorted(self.origdict, key=self.sortkey)) from logilab.common.testlib import TestCase @@ -279,7 +290,7 @@ except AttributeError: # const return x.value - return _orig_choose_term(self, sorted(sourceterms, key=get_key)) + return _orig_choose_term(self, DumbOrderedDict2(sourceterms, get_key)) def do_monkey_patch():