-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
topic: rewriterelated to the assertion rewrite mechanismrelated to the assertion rewrite mechanismtype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch
Description
Adding PYTEST_DONT_REWRITE to the docstring of a test module suppresses assertion rewrites; however, this does not work for plugins.
Minimal (contrieved) example:
plugin.py
"""PYTEST_DONT_REWRITE"""
print("hello, world")
run:
$ python -c 'import pytest, plugin; pytest.main()' -p plugin
hello, world
===================================== test session starts ======================================
platform linux -- Python 3.6.3, pytest-3.3.0, py-1.5.2, pluggy-0.6.0
rootdir: /tmp/foo, inifile:
collected 0 items
======================================= warnings summary =======================================
None
Module already imported so can not be re-written: plugin
-- Docs: http://doc.pytest.org/en/latest/warnings.html
================================== 1 warnings in 0.00 seconds ==================================
$ pip list
attrs (17.3.0)
pip (9.0.1)
pluggy (0.6.0)
py (1.5.2)
pytest (3.3.0)
setuptools (28.8.0)
six (1.11.0)
Python 3.6 on Arch Linux.
Alternatively, it may also be nice if the warning was only output if there actually is at least one assert in the unrewritable module (or if -O is on which may make that impossible to check, perhaps).
Metadata
Metadata
Assignees
Labels
topic: rewriterelated to the assertion rewrite mechanismrelated to the assertion rewrite mechanismtype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch