Skip to content

Commit ecdbd45

Browse files
Stephen PascoeStephen Pascoe
authored andcommitted
Test case for canonicalise option.
1 parent 8d32bef commit ecdbd45

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/test_canonical.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
from nose.tools import *
3+
4+
from msgpack import packb
5+
6+
7+
def test_canonical():
8+
# This test serialises a dictionary 3 times.
9+
# Without canonicalisation each serialisation would be different
10+
# (on Python 2.6 anyway)
11+
d = {'year': 1, 'month': 2, 'day': 3}
12+
s1 = packb(d, canonical=True)
13+
14+
for i in range(30):
15+
d[i] = i
16+
for i in range(30):
17+
del d[i]
18+
s2 = packb(d, canonical=True)
19+
20+
d = dict(d)
21+
s3 = packb(d, canonical=True)
22+
23+
eq_(s1, s2, s3)
24+
25+
if __name__ == '__main__':
26+
from nose import main
27+
main()

0 commit comments

Comments
 (0)