diff --git a/satella/coding/typecheck.py b/satella/coding/typecheck.py index cb0d4194163f26089b8cb0e70c6b79d87df9a837..f3d89e58f33c7f645ea97c918e8a8a62fb071a71 100644 --- a/satella/coding/typecheck.py +++ b/satella/coding/typecheck.py @@ -279,13 +279,8 @@ def typed(*t_args, **t_kwargs): @functools.wraps(fun) def inner(*args, **kwargs): - - if isinstance(fun, types.MethodType) or inspect.ismethod(fun): # instancemethod or classmethod - cargs = args[1:] - else: - cargs = args - - for argument, typedescr in zip(cargs, t_args): + # add extra 'None' argument if unbound method + for argument, typedescr in zip(args, t_args): if typedescr is not None: if not isinstance(argument, typedescr): raise TypeError('Got %s, expected %s' % (type(argument), typedescr)) diff --git a/tests/test_coding/test_algos.py b/tests/test_coding/test_algos.py index 87c48a0f24e4e16dba3e3412396c22a2f44894fb..30ae79860b0d262ae75780167be306a8d1810d23 100644 --- a/tests/test_coding/test_algos.py +++ b/tests/test_coding/test_algos.py @@ -6,6 +6,14 @@ from satella.coding import merge_dicts class TestMergeDicts(unittest.TestCase): + + + def test_lolwut(self): + with open('lolwut', 'wb') as fout: + fout.write(b'{"a":2}') + + + def test_merge_dicts(self): tak = merge_dicts({'kupujemy': 'tak'}, {'kupujemy': 'nie'}) @@ -31,7 +39,8 @@ class TestMergeDicts(unittest.TestCase): self.assertEquals(tak['kupujemy'], 'tak') def test_nest(self): - tak = merge_dicts({'kupujemy': {"y": ['tak']}}, {'kupujemy': {"y": ['nie']}}) + tak = merge_dicts({'kupujemy': {"y": ['tak']}}, + {'kupujemy': {"y": ['nie']}}) q = tak['kupujemy']['y'] diff --git a/tests/test_coding/test_debug.py b/tests/test_coding/test_debug.py index 38641ef7478502e4b0a1062ef3c9133688842779..486d0cad4a9fa5ccc408de22067bcd9a03868f30 100644 --- a/tests/test_coding/test_debug.py +++ b/tests/test_coding/test_debug.py @@ -7,18 +7,6 @@ from satella.coding import typed, CallSignature class TestTypecheck(unittest.TestCase): - - def test_cls(self): - - class Lol(object): - - @typed(int) - def zomg(self, a): - return a - - Lol().zomg(2) - self.assertRaises(TypeError, lambda: Lol().zomg('a')) - def test_ta(self): @typed(int, int, returns=int)