1 year ago

#388851

test-img

Slava

How to ignore specific warning using Pytest?

Pytest has @pytest.mark.filterwarnings

using:

@pytest.mark.filterwarnings("ignore::DeprecationWarning")

works like a charm but I don't want to ignore all DeprecationWarning I want to ignore a specific one:

warnings.warn("Please use new_module.", DeprecationWarning)

I tried to do:

@pytest.mark.filterwarnings("ignore::DeprecationWarning: Please use new_module.")

but this doesn't work. I can't find the proper syntax to filter a specific message.

how can this be done?

python

pytest

0 Answers

Your Answer

Accepted video resources