How to suppress py.test internal deprecation warnings

前端 未结 5 702
清歌不尽
清歌不尽 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:26

    In the pytest.ini file you can add:

    [pytest]
    addopts = -p no:warnings
    

    OR passing below line in the command-line. This might be useful if your test suites handle warnings using an external system.

    -p no:warnings

    OR if you only want to hide some specific deprecated warning, add below statement in you pytest.ini file

    [pytest]
    filterwarnings =
        ignore:.*U.*mode is deprecated:DeprecationWarning
    

    This will ignore all warnings of type DeprecationWarning where the start of the message matches the regular expression ".*U.*mode is deprecated".

    OR Although not recommended, you can use the

    --disable-warnings

    command-line option to suppress the warning summary entirely from the test run output.

提交回复
热议问题