Mercurial > hg > pyloader
annotate tests/doctest.txt @ 7:79676a48f6d8
begin porting and modernizing instructions from wsgiblob to pyloader
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 24 May 2011 19:12:09 -0700 |
parents | a825f00fe062 |
children |
rev | line source |
---|---|
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
|
1 Test pyloader |
a825f00fe062
add a different call method, rename the old one, and have a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
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
|
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 |