Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/test/enum.py @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.1 KB
RevLine 
[29]1# Copyright David Abrahams 2004. Distributed under the Boost
2# Software License, Version 1.0. (See accompanying
3# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4'''
5>>> from enum_ext import *
6
7>>> identity(color.red)
8enum_ext.color.red
9
10>>> identity(color.green)
11enum_ext.color.green
12
13>>> identity(color.blue)
14enum_ext.color.blue
15
16>>> identity(color(1))
17enum_ext.color.red
18
19>>> identity(color(2))
20enum_ext.color.green
21
22>>> identity(color(3))
23enum_ext.color(3)
24
25>>> identity(color(4))
26enum_ext.color.blue
27
28  --- check export to scope ---
29
30>>> identity(red)
31enum_ext.color.red
32
33>>> identity(green)
34enum_ext.color.green
35
36>>> identity(blue)
37enum_ext.color.blue
38
39>>> try: identity(1)
40... except TypeError: pass
41... else: print 'expected a TypeError'
42
43>>> c = colorized()
44>>> c.x
45enum_ext.color.red
46>>> c.x = green
47>>> c.x
48enum_ext.color.green
49'''
50
51def run(args = None):
52    import sys
53    import doctest
54
55    if args is not None:
56        sys.argv = args
57    return doctest.testmod(sys.modules.get(__name__))
58   
59if __name__ == '__main__':
60    print "running..."
61    import sys
62    status = run()[0]
63    if (status == 0): print "Done."
64    sys.exit(status)
Note: See TracBrowser for help on using the repository browser.