Skip to content

Commit 7ec1a14

Browse files
committed
Incorporating feedback from asottile
1 parent 8a1afe4 commit 7ec1a14

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

doc/en/example/parametrize.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ Use :func:`pytest.raises` with the
569569
:ref:`pytest.mark.parametrize ref` decorator to write parametrized tests
570570
in which some tests raise exceptions and others do not.
571571

572-
It is helpful to define a context manager ``does_not_raise`` to serve
572+
It is helpful to define a no-op context manager ``does_not_raise`` to serve
573573
as a complement to ``raises``. For example::
574574

575575
from contextlib import contextmanager
@@ -594,7 +594,15 @@ as a complement to ``raises``. For example::
594594
In the example above, the first three test cases should run unexceptionally,
595595
while the fourth should raise ``ZeroDivisionError``.
596596

597-
In Python 3.7+, you can simply use ``nullcontext`` to define
598-
``does_not_raise``::
597+
If you're only supporting Python 3.7+, you can simply use ``nullcontext``
598+
to define ``does_not_raise``::
599599

600600
from contextlib import nullcontext as does_not_raise
601+
602+
Or, if you're supporting Python 3.3+ you can use::
603+
604+
from contextlib import ExitStack as does_not_raise
605+
606+
Or, if desired, you can ``pip install contextlib2`` and use::
607+
608+
from contextlib2 import ExitStack as does_not_raise

0 commit comments

Comments
 (0)