Skip to content

Commit 90be44c

Browse files
committed
Document PYTEST_DONT_REWRITE
Fixes #2203
1 parent 7dfdfa5 commit 90be44c

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

doc/en/assert.rst

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,21 @@ supporting modules which are not themselves test modules will not be rewritten.
270270

271271
.. note::
272272

273-
``pytest`` rewrites test modules on import. It does this by using an import
274-
hook to write new pyc files. Most of the time this works transparently.
273+
``pytest`` rewrites test modules on import by using an import
274+
hook to write new ``pyc`` files. Most of the time this works transparently.
275275
However, if you are messing with import yourself, the import hook may
276-
interfere. If this is the case, use ``--assert=plain``. Additionally,
277-
rewriting will fail silently if it cannot write new pycs, i.e. in a read-only
278-
filesystem or a zipfile.
276+
interfere.
277+
278+
If this is the case you have two options:
279+
280+
* Disable rewriting for a specific module by adding the string
281+
``PYTEST_DONT_REWRITE`` to its docstring.
282+
283+
* Disable rewriting for all modules by using ``--assert=plain``.
284+
285+
Additionally, rewriting will fail silently if it cannot write new ``.pyc`` files,
286+
i.e. in a read-only filesystem or a zipfile.
287+
279288

280289
For further information, Benjamin Peterson wrote up `Behind the scenes of pytest's new assertion rewriting <http://pybites.blogspot.com/2011/07/behind-scenes-of-pytests-new-assertion.html>`_.
281290

0 commit comments

Comments
 (0)