From b61b6138ec99aa9ab58b4ef2648769f04d23fb86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Aizpurua?= Date: Wed, 27 Jul 2022 18:47:43 +0200 Subject: [PATCH] merge pass remove --- doc/en/how-to/fixtures.rst | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/doc/en/how-to/fixtures.rst b/doc/en/how-to/fixtures.rst index de6829842..742f3c0e7 100644 --- a/doc/en/how-to/fixtures.rst +++ b/doc/en/how-to/fixtures.rst @@ -732,6 +732,12 @@ Here's how the previous example would look using the ``addfinalizer`` method: It's a bit longer than yield fixtures and a bit more complex, but it does offer some nuances for when you're in a pinch. +.. code-block:: pytest + + $ pytest -q test_emaillib.py + . [100%] + 1 passed in 0.12s + Note on finalizer order """""""""""""""""""""""" @@ -743,29 +749,25 @@ Consider the differences in the following examples: .. code-block:: python import pytest - from functools import partial @pytest.fixture - def fix_w_finalizers(request): - request.addfinalizer(partial(print, "finalizer_2")) - request.addfinalizer(partial(print, "finalizer_1")) + def test_bar(fix_w_yield1, fix_w_yield2): + print("test_bar") @pytest.fixture - def fix_w_yield(): + def fix_w_yield1(): yield print("after_yield_1") + + + @pytest.fixture + def fix_w_yield2(): + yield print("after_yield_2") - def test_foo(fix_w_finalizers): - print("test_foo") - - - def test_bar(fix_w_yield): - print("test_bar") - .. code-block:: pytest @@ -785,11 +787,7 @@ Consider the differences in the following examples: after_yield_2 -.. code-block:: pytest - $ pytest -q test_emaillib.py - . [100%] - 1 passed in 0.12s .. _`safe teardowns`: Safe teardowns