[testlib] take care of re-monkeypatching which'll cause infinite recursion error
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 04 Aug 2009 00:51:00 +0200
changeset 2668 979c7ccb4a86
parent 2667 c8aa82538d8e
child 2669 cab66dfe0db6
[testlib] take care of re-monkeypatching which'll cause infinite recursion error
devtools/testlib.py
--- a/devtools/testlib.py	Mon Aug 03 17:59:34 2009 +0200
+++ b/devtools/testlib.py	Tue Aug 04 00:51:00 2009 +0200
@@ -389,7 +389,10 @@
                                            requestcls=testclass.requestcls)
     for reg in env.vreg.values():
         reg._selected = {}
-        orig_select_best = reg.__class__.select_best
+        try:
+            orig_select_best = reg.__class__.__orig_select_best
+        except:
+            orig_select_best = reg.__class__.select_best
         def instr_select_best(self, *args, **kwargs):
             selected = orig_select_best(self, *args, **kwargs)
             try:
@@ -400,6 +403,7 @@
                 pass # occurs on reg used to restore database
             return selected
         reg.__class__.select_best = instr_select_best
+        reg.__class__.__orig_select_best = orig_select_best
 
 def print_untested_objects(testclass, skipregs=('hooks', 'etypes')):
     for regname, reg in testclass._env.vreg.iteritems():