factor out a small "wrapping" helper

This commit is contained in:
holger krekel
2014-10-04 15:49:31 +02:00
parent 2161b54555
commit 3d794b6b38
2 changed files with 49 additions and 10 deletions

View File

@@ -765,3 +765,23 @@ def test_importplugin_issue375(testdir):
assert "qwe" not in str(excinfo.value)
assert "aaaa" in str(excinfo.value)
def test_wrapping():
class A:
def f(self):
return "A.f"
shutdown = []
l = []
def f(self):
l.append(1)
x = yield
l.append(2)
undo = add_method_controller(A, f)
assert A().f() == "A.f"
assert l == [1,2]
undo()
l[:] = []
assert A().f() == "A.f"
assert l == []