From 31e83200b21ab0c09112cb2815438e6259f1c874 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 6 Jun 2017 19:44:32 +0200 Subject: fix problem in origin ancestry: don't add self twice Also add various comments to illustrate what is going on during origin resolution. In the regression tests' expectations, some duplicate entries in the origins are removed, and hence no list of deeper origin ancestry is printed anymore. Change-Id: I42c3b8635b54c31c27699140e200c1f75a6ada29 --- src/osmo_gsm_tester/log.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/osmo_gsm_tester/log.py b/src/osmo_gsm_tester/log.py index ede3b16..fb6d55b 100644 --- a/src/osmo_gsm_tester/log.py +++ b/src/osmo_gsm_tester/log.py @@ -352,10 +352,20 @@ class Origin: def gather_origins(self): origins = Origins() + # this object shall always be seen as the immediate origin of the log message. origins.add(self) + # now go through the parents of this object. origin = self._parent_origin + # but if this object is "loose" and not set up with cascaded 'with' statements, + # take the last seen 'with' statement's object as next parent: if origin is None and Origin._global_current_origin is not None: origin = Origin._global_current_origin + # if this object is currently the _global_current_origin, we don't + # need to add it twice. + if origin is self: + origin = origin._parent_origin + # whichever we determined to be the parent above, go up through all its + # ancestors. while origin is not None: origins.add(origin) origin = origin._parent_origin -- cgit v1.2.3