diff --git a/selftest/suite_test/suite_test.ok b/selftest/suite_test/suite_test.ok index dfc8d41e..2c49c195 100644 --- a/selftest/suite_test/suite_test.ok +++ b/selftest/suite_test/suite_test.ok @@ -160,7 +160,7 @@ modem trial test_suite hello_world.py ---------------------------------------------- tst hello_world.py:[LINENR]: hello world [test_suite↪hello_world.py:[LINENR]] -tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py:[LINENR]' [test_suite↪hello_world.py:[LINENR]] +tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py' [test_suite↪hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: one [test_suite↪hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: two [test_suite↪hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: three [test_suite↪hello_world.py:[LINENR]] @@ -187,7 +187,7 @@ trial test_suite ---------------------------------------------- trial test_suite test_error.py ---------------------------------------------- -tst test_error.py:[LINENR]: I am 'test_suite' / 'test_error.py:[LINENR]' [test_suite↪test_error.py:[LINENR]] [test_error.py:[LINENR]] +tst test_error.py:[LINENR]: I am 'test_suite' / 'test_error.py' [test_suite↪test_error.py:[LINENR]] [test_error.py:[LINENR]] tst test_error.py:[LINENR]: ERR: AssertionError: test_error.py:[LINENR]: assert False [test_suite↪test_error.py:[LINENR]] [test_error.py:[LINENR]: assert False] tst test_error.py:[LINENR]: Test FAILED (N.N sec) [test_suite↪test_error.py:[LINENR]] [test.py:[LINENR]] --------------------------------------------------------------------- @@ -212,7 +212,7 @@ trial test_suite ---------------------------------------------- trial test_suite test_fail.py ---------------------------------------------- -tst test_fail.py:[LINENR]: I am 'test_suite' / 'test_fail.py:[LINENR]' [test_suite↪test_fail.py:[LINENR]] [test_fail.py:[LINENR]] +tst test_fail.py:[LINENR]: I am 'test_suite' / 'test_fail.py' [test_suite↪test_fail.py:[LINENR]] [test_fail.py:[LINENR]] tst test_fail.py:[LINENR]: ERR: EpicFail: This failure is expected [test_suite↪test_fail.py:[LINENR]] [test_fail.py:[LINENR]] tst test_fail.py:[LINENR]: Test FAILED (N.N sec) [test_suite↪test_fail.py:[LINENR]] [test.py:[LINENR]] --------------------------------------------------------------------- @@ -389,7 +389,7 @@ modem trial test_suite hello_world.py ---------------------------------------------- tst hello_world.py:[LINENR]: hello world [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] -tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py:[LINENR]' [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] +tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py' [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: one [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: two [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: three [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] @@ -544,7 +544,7 @@ modem trial test_suite hello_world.py ---------------------------------------------- tst hello_world.py:[LINENR]: hello world [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] -tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py:[LINENR]' [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] +tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py' [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: one [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: two [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: three [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] @@ -745,7 +745,7 @@ trial test_suite trial test_suite hello_world.py ---------------------------------------------- tst hello_world.py:[LINENR]: hello world [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] -tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py:[LINENR]' [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] +tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py' [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: one [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: two [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: three [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] diff --git a/src/osmo_gsm_tester/core/log.py b/src/osmo_gsm_tester/core/log.py index b8182f5a..2b8db622 100644 --- a/src/osmo_gsm_tester/core/log.py +++ b/src/osmo_gsm_tester/core/log.py @@ -222,7 +222,7 @@ class LogTarget: if origin is None: name = '-' elif isinstance(origin, Origin): - name = origin.name() + name = origin.src() # only log ancestry when there is more than one if origin._parent is not None: deeper_origins = origin.ancestry_str() @@ -447,6 +447,12 @@ class Origin: def name(self): return self._name or self.__class__.__name__ + def src(self): + '''subclasses may override this to provide more detailed source + information with the name, for a backtrace. For example, a line number + in a test script.''' + return self.name() + __str__ = name __repr__ = name @@ -476,7 +482,7 @@ class Origin: return origins def ancestry_str(self): - return '↪'.join([o.name() for o in self.ancestry()]) + return '↪'.join([o.src() for o in self.ancestry()]) def highest_ancestor(self): if self._parent: diff --git a/src/osmo_gsm_tester/core/test.py b/src/osmo_gsm_tester/core/test.py index fd3ac047..896eb4cb 100644 --- a/src/osmo_gsm_tester/core/test.py +++ b/src/osmo_gsm_tester/core/test.py @@ -102,11 +102,11 @@ class Test(log.Origin): for log_tgt in self.log_targets: log_tgt.remove() - def name(self): + def src(self): l = log.get_line_for_src(self.path) if l is not None: - return '%s:%s' % (self._name, l) - return super().name() + return '%s:%s' % (self.name(), l) + return self.name() def elapsed_time(self): 'time elapsed since test was started'