annotate tests/test_call.txt @ 63:995b831041be

stub: override section: [foo:bar]
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 09 Jun 2011 09:15:48 -0700
parents d50d5237e82d
children 418289c0fe3c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
d50d5237e82d rename test file
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
1 Test call
d50d5237e82d rename test file
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
2 =========
5
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 Test the call method::
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 >>> from pyloader.invoke import call
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 >>> options = {'badarg': 'bar', 'a': 7, 'b': 9, 'c': 10}
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 >>> def foo(a, b=1, c=2):
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 ... return a + 10*b + 100*c
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 >>> foo(7, 9, 10)
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 1097
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 You can't call methods with bad arguments OOTB in python::
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 >>> error = None
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 >>> try:
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 ... foo(**options)
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 ... except TypeError, e:
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19 ... error = e
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 >>> type(error)
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 <type 'exceptions.TypeError'>
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 But you can with call::
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 >>> call(foo, **options)
a825f00fe062 add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26 1097