MCPcopy Index your code
hub / github.com/python/cpython / test_marshal

Function test_marshal

Lib/test/audit-tests.py:112–135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

110
111
112def test_marshal():
113 import marshal
114 o = ("a", "b", "c", 1, 2, 3)
115 payload = marshal.dumps(o)
116
117 with TestHook() as hook:
118 assertEqual(o, marshal.loads(marshal.dumps(o)))
119
120 try:
121 with open("test-marshal.bin", "wb") as f:
122 marshal.dump(o, f)
123 with open("test-marshal.bin", "rb") as f:
124 assertEqual(o, marshal.load(f))
125 finally:
126 os.unlink("test-marshal.bin")
127
128 actual = [(a[0], a[1]) for e, a in hook.seen if e == "marshal.dumps"]
129 assertSequenceEqual(actual, [(o, marshal.version)] * 2)
130
131 actual = [a[0] for e, a in hook.seen if e == "marshal.loads"]
132 assertSequenceEqual(actual, [payload])
133
134 actual = [e for e, a in hook.seen if e == "marshal.load"]
135 assertSequenceEqual(actual, ["marshal.load"])
136
137
138def test_pickle():

Callers

nothing calls this directly

Calls 9

assertEqualFunction · 0.85
assertSequenceEqualFunction · 0.85
TestHookClass · 0.70
openFunction · 0.50
dumpsMethod · 0.45
loadsMethod · 0.45
dumpMethod · 0.45
loadMethod · 0.45
unlinkMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…