Commit 2b65e3ae authored by Julien Muchembled's avatar Julien Muchembled

qa: make Patch work on functions

parent 823e831f
...@@ -29,6 +29,7 @@ import MySQLdb ...@@ -29,6 +29,7 @@ import MySQLdb
import transaction import transaction
from functools import wraps from functools import wraps
from inspect import isclass
from .mock import Mock from .mock import Mock
from neo.lib import debug, logging, protocol from neo.lib import debug, logging, protocol
from neo.lib.protocol import NodeTypes, Packets, UUID_NAMESPACES from neo.lib.protocol import NodeTypes, Packets, UUID_NAMESPACES
...@@ -463,9 +464,12 @@ class Patch(object): ...@@ -463,9 +464,12 @@ class Patch(object):
self._patch = patch self._patch = patch
try: try:
orig = patched.__dict__[name] orig = patched.__dict__[name]
self._revert = lambda: setattr(patched, name, orig)
except KeyError: except KeyError:
self._revert = lambda: delattr(patched, name) if new or isclass(patched):
self._revert = lambda: delattr(patched, name)
return
orig = getattr(patched, name)
self._revert = lambda: setattr(patched, name, orig)
def apply(self): def apply(self):
assert not self.applied assert not self.applied
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment