Skip to content

Commit 03c3a90

Browse files
committed
runner: replace setdefault with an unconditional set
The already-exists case is not supposed to happen.
1 parent 960ebae commit 03c3a90

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/_pytest/runner.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,10 @@ def prepare(self, colitem: Item) -> None:
422422

423423
needed_collectors = colitem.listchain()
424424
for col in needed_collectors[len(self.stack) :]:
425+
assert col not in self.stack
426+
assert col not in self._finalizers
425427
self.stack.append(col)
426-
self._finalizers.setdefault(col, [])
428+
self._finalizers[col] = []
427429
try:
428430
col.setup()
429431
except TEST_OUTCOME as e:

0 commit comments

Comments
 (0)