def test_function_kwargs(self):
        "test function with kw args, no **kws"
        self.trytext("""
def fcn(square=False, x=0, y=0, z=0, t=0):
    'test varargs function'
    out = 0
    for i in (x, y, z, t):
        if square:
            out = out + i*i
        else:
            out = out + i
        endif
    endfor
    return out
enddef
""")
        self.NoExceptionRaised()
        out, err = self.trytext("print(fcn)")
        self.NoExceptionRaised()
        out = out.split('\n')
        self.assert_(out[0].startswith('<Procedure fcn(square'))

        self.trytext("o = fcn(x=1, y=2, z=3, square=False)")
        self.NoExceptionRaised()
        self.isValue('o', 6)

        self.trytext("o = fcn(x=1, y=2, z=3, square=True)")
        self.NoExceptionRaised()
        self.isValue('o', 14)

        self.trytext("o = fcn(x=1, y=2, z=3, t=-2)")
        self.NoExceptionRaised()
        self.isValue('o', 4)

        out, err = self.trytext("o = fcn(x=1, y=2, z=3, t=-12, s=1)")
        self.ExceptionRaised()
        errtype, errmsg = err[0].get_error()
        self.assertTrue(errtype == 'TypeError')
        self.assertTrue('extra keyword arg' in errmsg)
dataset/ETHPy150Open xraypy/xraylarch/tests/test_funccalls.py/TestEval.test_function_kwargs/original