kopia lustrzana https://github.com/micropython/micropython-lib
pickle: test_pickle.py: Turn into real test, add more cases.
Including a test for arbitrary statement execution.pull/255/head
rodzic
4328dde8f8
commit
66f147a761
|
@ -2,6 +2,23 @@ import pickle
|
|||
import sys
|
||||
import io
|
||||
|
||||
pickle.dump({1:2}, sys.stdout)
|
||||
|
||||
print(pickle.loads("{4:5}"))
|
||||
def roundtrip(val):
|
||||
t = pickle.dumps(val)
|
||||
t = pickle.loads(t)
|
||||
assert t == val
|
||||
|
||||
|
||||
roundtrip(1)
|
||||
roundtrip(1.0)
|
||||
roundtrip("str")
|
||||
roundtrip(b"bytes")
|
||||
roundtrip((1,))
|
||||
roundtrip([1, 2])
|
||||
roundtrip({1:2, 3: 4})
|
||||
|
||||
try:
|
||||
pickle.loads("1; import micropython")
|
||||
assert 0, "SyntaxError expected"
|
||||
except SyntaxError:
|
||||
pass
|
||||
|
|
Ładowanie…
Reference in New Issue