Wednesday, April 27, 2022

[FIXED] How to ignore SAWarning in pytest

Issue

I get this warning:

/app/facelo/extensions.py:36: SAWarning: DELETE statement on table 'trials' expected to delete 1 row(s); 0 were matched. Please set confirm_deleted_rows=False within the mapper configuration to prevent this warning.

I want to ignore it. I tried to use:

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

It gives me:

INTERNALERROR> warnings._OptionError: unknown warning category: 'SAWarning'

So it doesn't work because pytest doesn't know this warning. How can Ignore this warning?


Solution

In this question, can pytest ignore a specific warning? , they supply the full path to the exception. They are using a configuration file but try that with the SAWarning using mark.

@pytest.mark.filterwarnings("ignore::sqlalchemy.exc.SAWarning")


Answered By - Ian Wilson
Answer Checked By - Marie Seifert (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.