Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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)
Esempio n. 4
0
 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)
Esempio n. 5
0
 def test_type(self):
     s = String()
     s.name = 'x'
     with self.assertRaises(TypeError):
         s.type_check(123)
Esempio n. 6
0
 def test_type(self):
     s = String()
     s.name = 'x'
     with self.assertRaises(TypeError):
         s.type_check(123)