summaryrefslogtreecommitdiff
path: root/mocker.py
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2007-11-11 22:11:24 -0200
committerGustavo Niemeyer <gustavo@niemeyer.net>2007-11-11 22:11:24 -0200
commit02c0298f780d8dcb435fad8967de2a956ac78d14 (patch)
tree65228f4810393771ef0d69627c81462e35b135a3 /mocker.py
parent990945320feecf1c5352382c1de2ec86bf6993b2 (diff)
downloadmocker-02c0298f780d8dcb435fad8967de2a956ac78d14.tar.gz
Fixed SpecChecker to not break with callables not supported by
getargspec (e.g. builtin functions).
Diffstat (limited to 'mocker.py')
-rw-r--r--mocker.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/mocker.py b/mocker.py
index 9463702..f31cf53 100644
--- a/mocker.py
+++ b/mocker.py
@@ -1581,13 +1581,19 @@ class SpecChecker(Task):
def __init__(self, method):
self._method = method
+ self._unsupported = False
+
if method:
- self._args, self._varargs, self._varkwargs, self._defaults = \
- inspect.getargspec(method)
- if self._defaults is None:
- self._defaults = ()
- if type(method) is type(self.run):
- self._args = self._args[1:]
+ try:
+ self._args, self._varargs, self._varkwargs, self._defaults = \
+ inspect.getargspec(method)
+ except TypeError:
+ self._unsupported = True
+ else:
+ if self._defaults is None:
+ self._defaults = ()
+ if type(method) is type(self.run):
+ self._args = self._args[1:]
def get_method(self):
return self._method
@@ -1601,6 +1607,8 @@ class SpecChecker(Task):
def run(self, path):
if not self._method:
raise AssertionError("Method not found in real specification")
+ if self._unsupported:
+ return # Can't check it. Happens with builtin functions. :-(
action = path.actions[-1]
obtained_len = len(action.args)
obtained_kwargs = action.kwargs.copy()