def test_load(self): s = String() s.name = 'x' o = Object() buf = b'\x00\x00\x00\x02ef' self.assertEqual(6, s.load(o, buf)) self.assertEqual('ef', o.x)
def test_store(self): s = String() s.name = 'x' o = Object() o.x = 'abc' buf = s.store(o) self.assertEqual(b'\x00\x00\x00\x03abc', buf)
def test_type(self): s = String() s.name = 'x' with self.assertRaises(TypeError): s.type_check(123)