示例#1
0
 def test_decode_record(self):
     msg = f('A|B|C|D')
     res = [['A', 'B', 'C', 'D']]
     self.assertEqual(res, codec.decode(msg))
示例#2
0
 def test_decode_message_with_nonascii(self):
     msg = f('{STX}1Й|Ц|У|К{CR}{ETX}F1{CRLF}', 'cp1251')
     res = [[u('Й'), u('Ц'), u('У'), u('К')]]
     self.assertEqual(res, codec.decode(msg, 'cp1251'))
示例#3
0
 def test_decode_frame(self):
     msg = f('1A|B|C|D{CR}{ETX}')
     res = [['A', 'B', 'C', 'D']]
     self.assertEqual(res, codec.decode(msg))
示例#4
0
 def test_join_chunks(self):
     recs = [['foo', '1'], ['bar', '24'], ['baz', ['1', '2', '3'], 'boo']]
     chunks = codec.encode(recs, size=14)
     msg = codec.join(chunks)
     self.assertEqual(codec.decode(msg), recs)
示例#5
0
 def test_decode_message(self):
     msg = f('{STX}1A|B|C|D{CR}{ETX}BF{CRLF}')
     res = [['A', 'B', 'C', 'D']]
     self.assertEqual(res, codec.decode(msg))
示例#6
0
 def test_decode_record(self):
     msg = f("A|B|C|D")
     res = [["A", "B", "C", "D"]]
     self.assertEqual(res, codec.decode(msg))
示例#7
0
 def test_decode_chunks(self):
     recs = [['foo', 1], ['bar', 24], ['baz', [1, 2, 3], 'boo']]
     res = codec.encode(recs, size=14)
     for item in res:
         codec.decode(item)
示例#8
0
 def test_decode_frame(self):
     msg = f("1A|B|C|D{CR}{ETX}")
     res = [["A", "B", "C", "D"]]
     self.assertEqual(res, codec.decode(msg))
示例#9
0
 def test_decode_message_with_nonascii(self):
     msg = f("{STX}1Й|Ц|У|К{CR}{ETX}F1{CRLF}", "cp1251")
     res = [[u("Й"), u("Ц"), u("У"), u("К")]]
     self.assertEqual(res, codec.decode(msg, "cp1251"))
示例#10
0
 def test_decode_message(self):
     msg = f("{STX}1A|B|C|D{CR}{ETX}BF{CRLF}")
     res = [["A", "B", "C", "D"]]
     self.assertEqual(res, codec.decode(msg))
示例#11
0
 def test_join_chunks(self):
     recs = [["foo", "1"], ["bar", "24"], ["baz", ["1", "2", "3"], "boo"]]
     chunks = codec.encode(recs, size=14)
     msg = codec.join(chunks)
     self.assertEqual(codec.decode(msg), recs)
示例#12
0
 def test_decode_chunks(self):
     recs = [["foo", 1], ["bar", 24], ["baz", [1, 2, 3], "boo"]]
     res = codec.encode(recs, size=14)
     for item in res:
         codec.decode(item)