From 005e012a78473ab14c34ef5eb12dd68f8638f5b9 Mon Sep 17 00:00:00 2001 From: Piotr Maslanka <piotr.maslanka@henrietta.com.pl> Date: Tue, 5 Sep 2017 22:09:41 +0200 Subject: [PATCH] won't do --- satella/coding/typecheck.py | 9 ++------- tests/test_coding/test_algos.py | 11 ++++++++++- tests/test_coding/test_debug.py | 12 ------------ 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/satella/coding/typecheck.py b/satella/coding/typecheck.py index cb0d4194..f3d89e58 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 87c48a0f..30ae7986 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 38641ef7..486d0cad 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) -- GitLab