blob: 2e93480b21c0aeb08e99759735e9ff0ff4467d37 [file] [log] [blame]
Jeremy Hylton6eb4b6a1997-08-15 15:59:43 +00001import zlib
2import sys
Guido van Rossumc95a6c11997-08-15 16:23:32 +00003import imp
Jeremy Hylton6eb4b6a1997-08-15 15:59:43 +00004
Guido van Rossumc95a6c11997-08-15 16:23:32 +00005t = imp.find_module('test_zlib')
6file = t[0]
7buf = file.read() * 8
8file.close()
Jeremy Hylton6eb4b6a1997-08-15 15:59:43 +00009
10x = zlib.compress(buf)
11y = zlib.decompress(x)
12if buf != y:
13 print "normal compression/decompression failed"
14
15buf = buf * 16
16
17co = zlib.compressobj(8, 8, -15)
18x1 = co.compress(buf)
19x2 = co.flush()
20x = x1 + x2
21
22dc = zlib.decompressobj(-15)
23y1 = dc.decompress(x)
24y2 = dc.flush()
25y = y1 + y2
26if buf != y:
27 print "compress/decompression obj failed"
28
29def ignore():
30 """An empty function with a big string.
31
32 Make the compression algorithm work a little harder.
33 """
34
35 """
36LAERTES
37
38 O, fear me not.
39 I stay too long: but here my father comes.
40
41 Enter POLONIUS
42
43 A double blessing is a double grace,
44 Occasion smiles upon a second leave.
45
46LORD POLONIUS
47
48 Yet here, Laertes! aboard, aboard, for shame!
49 The wind sits in the shoulder of your sail,
50 And you are stay'd for. There; my blessing with thee!
51 And these few precepts in thy memory
52 See thou character. Give thy thoughts no tongue,
53 Nor any unproportioned thought his act.
54 Be thou familiar, but by no means vulgar.
55 Those friends thou hast, and their adoption tried,
56 Grapple them to thy soul with hoops of steel;
57 But do not dull thy palm with entertainment
58 Of each new-hatch'd, unfledged comrade. Beware
59 Of entrance to a quarrel, but being in,
60 Bear't that the opposed may beware of thee.
61 Give every man thy ear, but few thy voice;
62 Take each man's censure, but reserve thy judgment.
63 Costly thy habit as thy purse can buy,
64 But not express'd in fancy; rich, not gaudy;
65 For the apparel oft proclaims the man,
66 And they in France of the best rank and station
67 Are of a most select and generous chief in that.
68 Neither a borrower nor a lender be;
69 For loan oft loses both itself and friend,
70 And borrowing dulls the edge of husbandry.
71 This above all: to thine ownself be true,
72 And it must follow, as the night the day,
73 Thou canst not then be false to any man.
74 Farewell: my blessing season this in thee!
75
76LAERTES
77
78 Most humbly do I take my leave, my lord.
79
80LORD POLONIUS
81
82 The time invites you; go; your servants tend.
83
84LAERTES
85
86 Farewell, Ophelia; and remember well
87 What I have said to you.
88
89OPHELIA
90
91 'Tis in my memory lock'd,
92 And you yourself shall keep the key of it.
93
94LAERTES
95
96 Farewell.
97"""
98