You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/en/assert.rst
+14-5Lines changed: 14 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -270,12 +270,21 @@ supporting modules which are not themselves test modules will not be rewritten.
270
270
271
271
.. note::
272
272
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.
275
275
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
+
279
288
280
289
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>`_.
0 commit comments