How to suppress py.test internal deprecation warnings

前端 未结 5 704
清歌不尽
清歌不尽 2020-12-12 19:47

Is there a way to suppress the pytest\'s internal deprecation warnings?

Context: I\'m looking to evaluate the difficulty of porting a test suite from nose

5条回答
  •  不思量自难忘°
    2020-12-12 20:37

    pytest -p no:warnings, or add the following to your pytest.ini or tox.ini:

    [pytest]
    addopts = -p no:warnings
    

    The result will be green without any indication of warnings. See documentation at https://docs.pytest.org/en/latest/warnings.html#disabling-warnings-summary.

    This can be a valid use case for a test suite where you want clean output.

    Be aware that always hiding all warnings may cause you to miss important warnings. If you want to hide only specific warnings, look at Cloc's answer.

提交回复
热议问题