annotate tests/test_call.txt @ 90:fa2c4db30e81

update setup.py
author Jeff Hammel <k0scist@gmail.com>
date Wed, 12 Apr 2017 11:46:57 -0700
parents 418289c0fe3c
children
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}
85
418289c0fe3c STUB: tests/test_call.txt tests/test_factory.txt
Jeff Hammel <k0scist@gmail.com>
parents: 12
diff changeset
8 >>> def foo(a, b=1, c=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
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