We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4328dde commit 66f147aCopy full SHA for 66f147a
pickle/test_pickle.py
@@ -2,6 +2,23 @@
2
import sys
3
import io
4
5
-pickle.dump({1:2}, sys.stdout)
6
7
-print(pickle.loads("{4:5}"))
+def roundtrip(val):
+ t = pickle.dumps(val)
8
+ t = pickle.loads(t)
9
+ assert t == val
10
+
11
12
+roundtrip(1)
13
+roundtrip(1.0)
14
+roundtrip("str")
15
+roundtrip(b"bytes")
16
+roundtrip((1,))
17
+roundtrip([1, 2])
18
+roundtrip({1:2, 3: 4})
19
20
+try:
21
+ pickle.loads("1; import micropython")
22
+ assert 0, "SyntaxError expected"
23
+except SyntaxError:
24
+ pass
0 commit comments