mirror of
https://github.com/boostorg/python.git
synced 2026-01-21 17:12:22 +00:00
34 lines
817 B
Python
34 lines
817 B
Python
r'''>>> import pickle1
|
|
>>> import re
|
|
>>> import pickle
|
|
>>> pickle1.world.__module__
|
|
'pickle1'
|
|
>>> pickle1.world.__safe_for_unpickling__
|
|
1
|
|
>>> pickle1.world.__reduce__()
|
|
'world'
|
|
>>> assert re.match(
|
|
... "\(<extension class pickle1.world at [0-9a-fA-FxX]+>, \('Hello',\)\)",
|
|
... repr(pickle1.world('Hello').__reduce__()))
|
|
>>>
|
|
>>> wd = pickle1.world('California')
|
|
>>> pstr = pickle.dumps(wd)
|
|
>>> wl = pickle.loads(pstr)
|
|
>>> print wd.greet()
|
|
Hello from California!
|
|
>>> print wl.greet()
|
|
Hello from California!
|
|
'''
|
|
|
|
def run(args = None):
|
|
if args is not None:
|
|
import sys
|
|
sys.argv = args
|
|
import doctest, test_pickle1
|
|
return doctest.testmod(test_pickle1)
|
|
|
|
if __name__ == '__main__':
|
|
import sys
|
|
sys.exit(run()[0])
|
|
|