def test_getParamsDict_0(self): def f(a): return inspect.getargvalues(sys._getframe())[-1] getParams = _TypeCheckedFunction(f)._getParamsDict self.assertEquals(f(0), getParams(0)) self.assertEquals(f(a=0), getParams(a=0)) self.assertRaises(TypeError, getParams) self.assertRaises(TypeError, getParams, 1, 2) self.assertRaises(TypeError, getParams, x=2)
def test_getParamsDict_1(self): def f(a, b=-1): return inspect.getargvalues(sys._getframe())[-1] getParams = _TypeCheckedFunction(f)._getParamsDict self.assertEquals(f(0), getParams(0)) self.assertEquals(f(a=0), getParams(a=0)) self.assertEquals(f(0,1), getParams(0,1)) self.assertEquals(f(0,b=1), getParams(0,b=1)) self.assertEquals(f(b=1,a=0), getParams(b=1,a=0)) self.assertRaises(TypeError, getParams) self.assertRaises(TypeError, getParams, x=2) self.assertRaises(TypeError, getParams, 1, 2, 3) self.assertRaises(TypeError, getParams, b=2) self.assertRaises(TypeError, getParams, 3, a=3) self.assertRaises(TypeError, getParams, 3, x=3)
def test_getParamsDict_1(self): def f(a, b=-1): return inspect.getargvalues(sys._getframe())[-1] getParams = _TypeCheckedFunction(f)._getParamsDict self.assertEquals(f(0), getParams(0)) self.assertEquals(f(a=0), getParams(a=0)) self.assertEquals(f(0, 1), getParams(0, 1)) self.assertEquals(f(0, b=1), getParams(0, b=1)) self.assertEquals(f(b=1, a=0), getParams(b=1, a=0)) self.assertRaises(TypeError, getParams) self.assertRaises(TypeError, getParams, x=2) self.assertRaises(TypeError, getParams, 1, 2, 3) self.assertRaises(TypeError, getParams, b=2) self.assertRaises(TypeError, getParams, 3, a=3) self.assertRaises(TypeError, getParams, 3, x=3)