Skip to content

Commit 1873dc6

Browse files
committed
Fix fixture example in docs
1 parent 693e9d0 commit 1873dc6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

doc/en/fixture.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,12 @@ close all resources created by a fixture even if one of them fails to be created
391391
392392
import pytest
393393
394-
from .utils import connect
394+
395+
@contextlib.contextmanager
396+
def connect(port):
397+
... # create connection
398+
yield
399+
... # close connection
395400
396401
397402
@pytest.fixture
@@ -441,7 +446,12 @@ Here's the ``equipments`` fixture changed to use ``addfinalizer`` for cleanup:
441446
442447
import pytest
443448
444-
from .utils import connect
449+
450+
@contextlib.contextmanager
451+
def connect(port):
452+
... # create connection
453+
yield
454+
... # close connection
445455
446456
447457
@pytest.fixture

0 commit comments

Comments
 (0)