From 1bb139121c5b42d61c0b075a9cd31e59a81d9d8e Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Tue, 17 Apr 2018 09:09:34 -0700 Subject: [PATCH] [toranj] update verify() to print line-no and test-name (#2662) --- tests/toranj/wpan.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/toranj/wpan.py b/tests/toranj/wpan.py index 2881ce8b0..85108f454 100644 --- a/tests/toranj/wpan.py +++ b/tests/toranj/wpan.py @@ -34,6 +34,7 @@ import weakref import subprocess import socket import asyncore +import inspect #---------------------------------------------------------------------------------------------------------------------- # wpantund properties @@ -724,8 +725,10 @@ class AsyncReceiver(asyncore.dispatcher): #----------------------------------------------------------------------------------------------------------------------- def verify(condition): + """Verifies that a `condition` is true, otherwise exits""" if not condition: - print 'verify() failed' + calling_frame = inspect.currentframe().f_back + print 'verify() failed at line {} in "{}"'.format(calling_frame.f_lineno, calling_frame.f_code.co_filename) exit(1)