2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-28 19:32:14 +00:00
Files
python/test/pickle3.py
2002-07-21 07:49:00 +00:00

39 lines
1.3 KiB
Python

r'''>>> import pickle3_ext
>>> import pickle
>>> pickle3_ext.world.__module__
'pickle3_ext'
>>> pickle3_ext.world.__safe_for_unpickling__
1
>>> pickle3_ext.world.__getstate_manages_dict__
1
>>> pickle3_ext.world.__name__
'world'
>>> pickle3_ext.world('Hello').__reduce__()
(<class 'pickle3_ext.world'>, ('Hello',), ({}, 0))
>>> for number in (24, 42):
... wd = pickle3_ext.world('California')
... wd.set_secret_number(number)
... wd.x = 2 * number
... wd.y = 'y' * number
... wd.z = 3. * number
... pstr = pickle.dumps(wd)
... wl = pickle.loads(pstr)
... print wd.greet(), wd.get_secret_number(), wd.x, wd.y, wd.z
... print wl.greet(), wl.get_secret_number(), wl.x, wl.y, wl.z
Hello from California! 24 48 yyyyyyyyyyyyyyyyyyyyyyyy 72.0
Hello from California! 24 48 yyyyyyyyyyyyyyyyyyyyyyyy 72.0
Hello from California! 42 84 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 126.0
Hello from California! 0 84 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 126.0
'''
def run(args = None):
if args is not None:
import sys
sys.argv = args
import doctest, pickle3
return doctest.testmod(pickle3)
if __name__ == '__main__':
import sys
sys.exit(run()[0])