From 7cf96fb0a1e8451ae8942c7079540356c068227b Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 3 Jun 2024 18:28:03 +1000 Subject: [PATCH] autotest: add a lineno method allows for debug like this: print(f"{self.lineno()} {self.mav.message_hooks=}") --- Tools/autotest/vehicle_test_suite.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Tools/autotest/vehicle_test_suite.py b/Tools/autotest/vehicle_test_suite.py index ae1684d6f007f..28f761e2ff82c 100644 --- a/Tools/autotest/vehicle_test_suite.py +++ b/Tools/autotest/vehicle_test_suite.py @@ -34,6 +34,7 @@ import tempfile import threading import enum +from inspect import currentframe, getframeinfo from pathlib import Path from MAVProxy.modules.lib import mp_util @@ -6417,6 +6418,12 @@ def verify_parameter_values(self, parameter_stuff, max_delta=0.0): ################################################# # UTILITIES ################################################# + def lineno(self): + '''return line number''' + frameinfo = getframeinfo(currentframe().f_back) + # print(frameinfo.filename, frameinfo.lineno) + return frameinfo.lineno + @staticmethod def longitude_scale(lat): ret = math.cos(lat * (math.radians(1)))