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 | r'''>>> import pickle3_ext |
---|
5 | >>> import pickle |
---|
6 | >>> pickle3_ext.world.__module__ |
---|
7 | 'pickle3_ext' |
---|
8 | >>> pickle3_ext.world.__safe_for_unpickling__ |
---|
9 | 1 |
---|
10 | >>> pickle3_ext.world.__getstate_manages_dict__ |
---|
11 | 1 |
---|
12 | >>> pickle3_ext.world.__name__ |
---|
13 | 'world' |
---|
14 | >>> pickle3_ext.world('Hello').__reduce__() |
---|
15 | (<class 'pickle3_ext.world'>, ('Hello',), ({}, 0)) |
---|
16 | >>> for number in (24, 42): |
---|
17 | ... wd = pickle3_ext.world('California') |
---|
18 | ... wd.set_secret_number(number) |
---|
19 | ... wd.x = 2 * number |
---|
20 | ... wd.y = 'y' * number |
---|
21 | ... wd.z = 3. * number |
---|
22 | ... pstr = pickle.dumps(wd) |
---|
23 | ... wl = pickle.loads(pstr) |
---|
24 | ... print wd.greet(), wd.get_secret_number(), wd.x, wd.y, wd.z |
---|
25 | ... print wl.greet(), wl.get_secret_number(), wl.x, wl.y, wl.z |
---|
26 | Hello from California! 24 48 yyyyyyyyyyyyyyyyyyyyyyyy 72.0 |
---|
27 | Hello from California! 24 48 yyyyyyyyyyyyyyyyyyyyyyyy 72.0 |
---|
28 | Hello from California! 42 84 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 126.0 |
---|
29 | Hello from California! 0 84 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 126.0 |
---|
30 | ''' |
---|
31 | |
---|
32 | def run(args = None): |
---|
33 | import sys |
---|
34 | import doctest |
---|
35 | |
---|
36 | if args is not None: |
---|
37 | sys.argv = args |
---|
38 | return doctest.testmod(sys.modules.get(__name__)) |
---|
39 | |
---|
40 | if __name__ == '__main__': |
---|
41 | print "running..." |
---|
42 | import sys |
---|
43 | status = run()[0] |
---|
44 | if (status == 0): print "Done." |
---|
45 | sys.exit(status) |
---|