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