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