view tests/test_call.txt @ 85:418289c0fe3c

STUB: tests/test_call.txt tests/test_factory.txt
author Jeff Hammel <k0scist@gmail.com>
date Fri, 21 Mar 2014 21:50:16 -0700
parents d50d5237e82d
children
line wrap: on
line source

Test call
=========

Test the call method::

    >>> from pyloader.invoke import call
    >>> options = {'badarg': 'bar', 'a': 7, 'b': 9, 'c': 10}
    >>> def foo(a, b=1, c=2):
    ...     return a + 10*b + 100*c
    >>> foo(7, 9, 10)
    1097

You can't call methods with bad arguments OOTB in python::

    >>> error = None
    >>> try:
    ...     foo(**options)
    ... except TypeError, e:
    ...     error = e
    >>> type(error)
    <type 'exceptions.TypeError'>

But you can with call::

    >>> call(foo, **options)
    1097