diff --git a/CHANGELOG b/CHANGELOG index 21f83fa5f..e3342a856 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -29,6 +29,7 @@ Changes between 2.1.3 and 2.2.0 - fix issue83: link to generated funcarg list - fix issue74: pyarg module names are now checked against imp.find_module false positives - fix compatibility with twisted/trial-11.1.0 use cases +- simplify Node.listchain Changes between 2.1.2 and 2.1.3 ---------------------------------------- diff --git a/_pytest/main.py b/_pytest/main.py index dc5e2b624..5d044021f 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -229,13 +229,13 @@ class Node(object): def listchain(self): """ return list of all parent collectors up to self, starting from root of collection tree. """ - l = [self] - while 1: - x = l[0] - if x.parent is not None: # and x.parent.parent is not None: - l.insert(0, x.parent) - else: - return l + chain = [] + item = self + while item is not None: + chain.append(item) + item = item.parent + chain.reverse() + return chain def listnames(self): return [x.name for x in self.listchain()]