From ca2cc3da2a0b218a8ada409c5b4c24baa716ee20 Mon Sep 17 00:00:00 2001 From: Yusuke Kadowaki Date: Sun, 27 Nov 2022 14:30:16 +0900 Subject: [PATCH] Refactor doc to use setdefault --- doc/en/example/simple.rst | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index d0ad693b0..d0e3501e0 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -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 # be "setup", "call", "teardown" - if your_unique_key not in item.stash: - item.stash[your_unique_key] = {rep.when: rep.passed} - else: - item.stash[your_unique_key][rep.when] = rep.passed + item.stash.setdefault(your_unique_key, {})[rep.when] = rep @pytest.fixture