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

Method test_transitiveness

Lib/test/test_struct.py:66–88  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

64 self.assertRaises(struct.error, struct.unpack, 'i', s)
65
66 def test_transitiveness(self):
67 c = b'a'
68 b = 1
69 h = 255
70 i = 65535
71 l = 65536
72 f = 3.1415
73 d = 3.1415
74 t = True
75
76 for prefix in ('', '@', '<', '>', '=', '!'):
77 for format in ('xcbhilfd?', 'xcBHILfd?'):
78 format = prefix + format
79 s = struct.pack(format, c, b, h, i, l, f, d, t)
80 cp, bp, hp, ip, lp, fp, dp, tp = struct.unpack(format, s)
81 self.assertEqual(cp, c)
82 self.assertEqual(bp, b)
83 self.assertEqual(hp, h)
84 self.assertEqual(ip, i)
85 self.assertEqual(lp, l)
86 self.assertEqual(int(100 * fp), int(100 * f))
87 self.assertEqual(int(100 * dp), int(100 * d))
88 self.assertEqual(tp, t)
89
90 def test_new_features(self):
91 # Test some of the new features in detail

Callers

nothing calls this directly

Calls 3

unpackMethod · 0.80
packMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected