Beispiel #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)
 def on_connect(self):
     self.read_delimiter = netstruct.NetStruct("ih$5b")
Beispiel #3
0
 def test_quantity_string(self):
     with self.assertRaises(netstruct.error):
         netstruct.NetStruct(b"i5$")
Beispiel #4
0
 def test_immediate_string(self):
     with self.assertRaises(netstruct.error):
         netstruct.NetStruct(b"$")
Beispiel #5
0
 def test_adjacent_strings(self):
     with self.assertRaises(netstruct.error):
         netstruct.NetStruct(b"b$$")
Beispiel #6
0
 def test_other_type(self):
     with self.assertRaises(TypeError):
         netstruct.NetStruct(42)
Beispiel #7
0
 def test_unicode(self):
     with self.assertRaises(TypeError):
         netstruct.NetStruct("ib")
Beispiel #8
0
 def test_empty(self):
     netstruct.NetStruct(b"")