diff -r 57875cf423c9 -r 2372284d9457 tests/test-extensions-wrapfunction.py --- a/tests/test-extensions-wrapfunction.py Sat Oct 05 10:29:34 2019 -0400 +++ b/tests/test-extensions-wrapfunction.py Sun Oct 06 09:45:02 2019 -0400 @@ -2,28 +2,36 @@ from mercurial import extensions + def genwrapper(x): def f(orig, *args, **kwds): return [x] + orig(*args, **kwds) + f.x = x return f + def getid(wrapper): return getattr(wrapper, 'x', '-') + wrappers = [genwrapper(i) for i in range(5)] + class dummyclass(object): def getstack(self): return ['orig'] + dummy = dummyclass() + def batchwrap(wrappers): for w in wrappers: extensions.wrapfunction(dummy, 'getstack', w) print('wrap %d: %s' % (getid(w), dummy.getstack())) + def batchunwrap(wrappers): for w in wrappers: result = None @@ -34,9 +42,14 @@ msg = e.__class__.__name__ print('unwrap %s: %s: %s' % (getid(w), getid(result), msg)) + batchwrap(wrappers + [wrappers[0]]) -batchunwrap([(wrappers[i] if i is not None and i >= 0 else None) - for i in [3, None, 0, 4, 0, 2, 1, None]]) +batchunwrap( + [ + (wrappers[i] if i is not None and i >= 0 else None) + for i in [3, None, 0, 4, 0, 2, 1, None] + ] +) wrap0 = extensions.wrappedfunction(dummy, 'getstack', wrappers[0]) wrap1 = extensions.wrappedfunction(dummy, 'getstack', wrappers[1]) @@ -59,6 +72,8 @@ class callableobj(object): def __call__(self): return ['orig'] + + dummy.cobj = callableobj() extensions.wrapfunction(dummy, 'cobj', wrappers[0]) print('wrap callable object', dummy.cobj())