PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 28, 2022

[FIXED] How to ignore all warnings except from one package in pytest?

 April 28, 2022     pytest, python, warnings     No comments   

Issue

When running pytest, I would like to ignore warnings from third-party packages. I know how to ignore one specific package (see https://stackoverflow.com/a/53218641/2057762), but how do I ignore all but one?


Solution

You need to set two filter rules:

[pytest]
filterwarnings =
    ignore
    default:::mypackage.*

You can apply multiple filters, so ignore everything and re-allow warnings for your package. The last one has highest precedence. Filter syntax is action:message:category:module:line. Possible actions and more details can be found in here.



Answered By - jns
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

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

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing