]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/test/test_enum.py
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)
5 >>> from enum_ext import *
7 >>> identity(color.red) # in case of duplicated enums it always take the last enum
10 >>> identity(color.green)
13 >>> identity(color.blue)
16 >>> identity(color(1)) # in case of duplicated enums it always take the last enum
19 >>> identity(color(2))
22 >>> identity(color(3))
25 >>> identity(color(4))
28 --- check export to scope ---
40 ... except TypeError: pass
41 ... else: print('expected a TypeError')
53 >>> hash(red) == hash(blood)
55 >>> hash(red) == hash(green)
59 # pickling of enums only works with Python 2.3 or higher
60 exercise_pickling
= '''
62 >>> p = pickle.dumps(color.green, pickle.HIGHEST_PROTOCOL)
63 >>> l = pickle.loads(p)
75 self
= sys
.modules
.get(__name__
)
76 if (hasattr(pickle
, "HIGHEST_PROTOCOL")):
77 self
.__doc
__ += exercise_pickling
78 return doctest
.testmod(self
)
80 if __name__
== '__main__':
84 if (status
== 0): print("Done.")