File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2
+ # For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt
3
+
4
+ [tool:pytest]
5
+ # How come these warnings are suppressed successfully here, but not in conftest.py??
6
+ filterwarnings =
7
+ # ignore all DeprecationWarnings...
8
+ ignore::DeprecationWarning
9
+ # ...but show them if they are from our code.
10
+ default::DeprecationWarning:django_coverage_plugin
Original file line number Diff line number Diff line change
1
+ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2
+ # For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt
3
+
4
+ """
5
+ Pytest auto configuration.
6
+
7
+ This module is run automatically by pytest, to define and enable fixtures.
8
+ """
9
+
10
+ import re
11
+ import warnings
12
+
13
+ import django .utils .deprecation
14
+ import pytest
15
+
16
+
17
+ @pytest .fixture (autouse = True )
18
+ def set_warnings ():
19
+ """Configure warnings to show while running tests."""
20
+ warnings .simplefilter ("default" )
21
+ warnings .simplefilter ("once" , DeprecationWarning )
22
+
23
+ # Warnings to suppress:
24
+ # How come these warnings are successfully suppressed here, but not in setup.cfg??
25
+
26
+ # We know we do tricky things with Django settings, don't warn us about it.
27
+ warnings .filterwarnings (
28
+ "ignore" ,
29
+ category = UserWarning ,
30
+ message = r"Overriding setting DATABASES can lead to unexpected behavior." ,
31
+ )
32
+
33
+ # Django has warnings like RemovedInDjango40Warning. We use features that are going to be
34
+ # deprecated, so we don't need to see those warnings. But the specific warning classes change
35
+ # in every release. Find them and ignore them.
36
+ for name , obj in vars (django .utils .deprecation ).items ():
37
+ if re .match (r"RemovedInDjango\d+Warning" , name ):
38
+ warnings .filterwarnings ("ignore" , category = obj )
You can’t perform that action at this time.
0 commit comments