Mercurial > hg > pyloader
comparison tests/test_call.txt @ 12:d50d5237e82d
rename test file
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 27 May 2011 07:19:17 -0700 |
parents | tests/doctest.txt@a825f00fe062 |
children | 418289c0fe3c |
comparison
equal
deleted
inserted
replaced
11:ff272dcd5cd8 | 12:d50d5237e82d |
---|---|
1 Test call | |
2 ========= | |
3 | |
4 Test the call method:: | |
5 | |
6 >>> from pyloader.invoke import call | |
7 >>> options = {'badarg': 'bar', 'a': 7, 'b': 9, 'c': 10} | |
8 >>> def foo(a, b=1, c=2): | |
9 ... return a + 10*b + 100*c | |
10 >>> foo(7, 9, 10) | |
11 1097 | |
12 | |
13 You can't call methods with bad arguments OOTB in python:: | |
14 | |
15 >>> error = None | |
16 >>> try: | |
17 ... foo(**options) | |
18 ... except TypeError, e: | |
19 ... error = e | |
20 >>> type(error) | |
21 <type 'exceptions.TypeError'> | |
22 | |
23 But you can with call:: | |
24 | |
25 >>> call(foo, **options) | |
26 1097 |