Refactor doc to use setdefault

This commit is contained in:
Yusuke Kadowaki 2022-11-27 14:30:16 +09:00
parent 83ab8be5f6
commit ca2cc3da2a
1 changed files with 1 additions and 4 deletions

View File

@ -906,10 +906,7 @@ here is a little example implemented via a local plugin:
# store test results for each phase of a call, which can # store test results for each phase of a call, which can
# be "setup", "call", "teardown" # be "setup", "call", "teardown"
if your_unique_key not in item.stash: item.stash.setdefault(your_unique_key, {})[rep.when] = rep
item.stash[your_unique_key] = {rep.when: rep.passed}
else:
item.stash[your_unique_key][rep.when] = rep.passed
@pytest.fixture @pytest.fixture