diff options
Diffstat (limited to 'gr-blocks/python/blocks/qa_message_strobe.py')
-rw-r--r-- | gr-blocks/python/blocks/qa_message_strobe.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/gr-blocks/python/blocks/qa_message_strobe.py b/gr-blocks/python/blocks/qa_message_strobe.py index 2f11a1d5c8..8e5eb91738 100644 --- a/gr-blocks/python/blocks/qa_message_strobe.py +++ b/gr-blocks/python/blocks/qa_message_strobe.py @@ -17,6 +17,8 @@ import time # similar tests contained in message_debug class # this tests the periodic message output and the input port to change the message + + class qa_message_strobe(gr_unittest.TestCase): def setUp(self): @@ -29,18 +31,22 @@ class qa_message_strobe(gr_unittest.TestCase): test_str = "test_msg" new_msg = "new_msg" message_period_ms = 100 - msg_strobe = blocks.message_strobe(pmt.intern(test_str), message_period_ms) + msg_strobe = blocks.message_strobe( + pmt.intern(test_str), message_period_ms) msg_debug = blocks.message_debug() self.tb.msg_connect(msg_strobe, "strobe", msg_debug, "store") self.tb.start() - self.assertAlmostEqual(msg_debug.num_messages(), 0, delta=2) # 1st call, expect 0 - time.sleep(1) # floor(1000/100) = 10 - self.assertAlmostEqual(msg_debug.num_messages(), 10, delta=3) # 2nd call == 1 - time.sleep(1) # floor(2000/100) = 15 - self.assertAlmostEqual(msg_debug.num_messages(), 20, delta=3) # 3th call == 3 + self.assertAlmostEqual(msg_debug.num_messages(), + 0, delta=2) # 1st call, expect 0 + time.sleep(1) # floor(1000/100) = 10 + self.assertAlmostEqual(msg_debug.num_messages(), + 10, delta=3) # 2nd call == 1 + time.sleep(1) # floor(2000/100) = 15 + self.assertAlmostEqual(msg_debug.num_messages(), + 20, delta=3) # 3th call == 3 # change test message msg_strobe.to_basic_block()._post(pmt.intern("set_msg"), pmt.intern(new_msg)) @@ -51,11 +57,14 @@ class qa_message_strobe(gr_unittest.TestCase): # check data # first received message matchs initial test message - self.assertAlmostEqual(pmt.to_python(msg_debug.get_message(0)), test_str, "mismatch initial test string") + self.assertAlmostEqual(pmt.to_python(msg_debug.get_message( + 0)), test_str, "mismatch initial test string") # last message matches changed test message no_msgs = msg_debug.num_messages() - self.assertAlmostEqual(pmt.to_python(msg_debug.get_message(no_msgs - 1)), new_msg, "failed to update string") + self.assertAlmostEqual(pmt.to_python(msg_debug.get_message( + no_msgs - 1)), new_msg, "failed to update string") + if __name__ == '__main__': gr_unittest.run(qa_message_strobe) |