summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrej Rode <mail@andrejro.de>2018-08-05 23:42:08 +0200
committerMarcus Müller <marcus@hostalia.de>2018-08-17 18:18:20 +0200
commitf0f838e3f0484c6156bf20164af1bfa7ff150587 (patch)
tree6d42d1c55d7e5428cd143cb800f9310f73a59b9f
parent2727e413a26024b17e649bc370afc45503173af6 (diff)
message: fix unit tests to respect mesage::to_string behaviour
Formerly to_string() returned a byte string in Python2 and a unicode string in Python3. To get the same behaviour for Python2 and Python3 the Unicode String in Python3 is converted to bytes. Which is a desired behaviour for to_string() since the carried payload of messages includes invalid unicode characters.
-rw-r--r--gr-blocks/python/blocks/qa_message.py4
-rw-r--r--gr-digital/python/digital/qa_framer_sink.py4
2 files changed, 4 insertions, 4 deletions
diff --git a/gr-blocks/python/blocks/qa_message.py b/gr-blocks/python/blocks/qa_message.py
index 639001f09a..1a3d250ab3 100644
--- a/gr-blocks/python/blocks/qa_message.py
+++ b/gr-blocks/python/blocks/qa_message.py
@@ -58,8 +58,8 @@ class test_message(gr_unittest.TestCase):
self.assertEquals(0, msg.length())
def test_101(self):
- s = 'This is a test'
- msg = gr.message_from_string(s)
+ s = b'This is a test'
+ msg = gr.message_from_string(s.decode('utf8'))
self.assertEquals(s, msg.to_string())
def test_200(self):
diff --git a/gr-digital/python/digital/qa_framer_sink.py b/gr-digital/python/digital/qa_framer_sink.py
index 555bc121f8..25e2902f72 100644
--- a/gr-digital/python/digital/qa_framer_sink.py
+++ b/gr-digital/python/digital/qa_framer_sink.py
@@ -52,7 +52,7 @@ class test_framker_sink(gr_unittest.TestCase):
header = tuple(2*[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]) # len=1
pad = (0,) * 100
src_data = code + header + (0,1,0,0,0,0,0,1) + pad
- expected_data = 'A'
+ expected_data = b'A'
rcvd_pktq = gr.msg_queue()
@@ -76,7 +76,7 @@ class test_framker_sink(gr_unittest.TestCase):
header = tuple(2*[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0]) # len=2
pad = (0,) * 100
src_data = code + header + (0,1,0,0,1,0,0,0) + (0,1,0,0,1,0,0,1) + pad
- expected_data = 'HI'
+ expected_data = b'HI'
rcvd_pktq = gr.msg_queue()