mirror of
https://github.com/boostorg/python.git
synced 2026-01-24 18:12:43 +00:00
fixes to support pickling of enums (by Shashank Bapat)
[SVN r36256]
This commit is contained in:
17
test/enum.py
17
test/enum.py
@@ -48,14 +48,27 @@ enum_ext.color.red
|
||||
enum_ext.color.green
|
||||
'''
|
||||
|
||||
# pickling of enums only works with Python 2.3 or higher
|
||||
exercise_pickling = '''
|
||||
>>> import pickle
|
||||
>>> p = pickle.dumps(color.green, pickle.HIGHEST_PROTOCOL)
|
||||
>>> l = pickle.loads(p)
|
||||
>>> identity(l)
|
||||
enum_ext.color.green
|
||||
'''
|
||||
|
||||
def run(args = None):
|
||||
import sys
|
||||
import doctest
|
||||
import pickle
|
||||
|
||||
if args is not None:
|
||||
sys.argv = args
|
||||
return doctest.testmod(sys.modules.get(__name__))
|
||||
|
||||
self = sys.modules.get(__name__)
|
||||
if (hasattr(pickle, "HIGHEST_PROTOCOL")):
|
||||
self.__doc__ += exercise_pickling
|
||||
return doctest.testmod(self)
|
||||
|
||||
if __name__ == '__main__':
|
||||
print "running..."
|
||||
import sys
|
||||
|
||||
Reference in New Issue
Block a user