Exemplo n.º 1
0
    def test_parsing(self):
        ns = netstruct.NetStruct(b"ih$5b")

        self.assertEqual(len(ns._pairs), 2)
        self.assertEqual(ns.minimum_size, 11)
        self.assertEqual(ns.initial_size, 6)
        self.assertEqual(ns.count, 7)
Exemplo n.º 2
0
 def on_connect(self):
     self.read_delimiter = netstruct.NetStruct("ih$5b")
Exemplo n.º 3
0
 def test_quantity_string(self):
     with self.assertRaises(netstruct.error):
         netstruct.NetStruct(b"i5$")
Exemplo n.º 4
0
 def test_immediate_string(self):
     with self.assertRaises(netstruct.error):
         netstruct.NetStruct(b"$")
Exemplo n.º 5
0
 def test_adjacent_strings(self):
     with self.assertRaises(netstruct.error):
         netstruct.NetStruct(b"b$$")
Exemplo n.º 6
0
 def test_other_type(self):
     with self.assertRaises(TypeError):
         netstruct.NetStruct(42)
Exemplo n.º 7
0
 def test_unicode(self):
     with self.assertRaises(TypeError):
         netstruct.NetStruct("ib")
Exemplo n.º 8
0
 def test_empty(self):
     netstruct.NetStruct(b"")