Skip to content

Commit dc5a43f

Browse files
hoffassenchenko
andauthored
ci: fail tests on warnings (#3248)
Co-authored-by: Slava Senchenko <[email protected]>
1 parent 8b9e24f commit dc5a43f

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

pytest.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,14 @@ markers =
77
slow: marks tests as slow (deselect with '-m "not slow"')
88
log_cli = 1
99
log_cli_level = INFO
10+
filterwarnings =
11+
error
12+
# From our own tests
13+
ignore:__init__ is deprecated and will be removed in a future release:DeprecationWarning
14+
ignore:deprecated_function is deprecated and will be removed in a future release, please use replacement_function:DeprecationWarning
15+
# Python 3.7 deprecation
16+
ignore::boto3.exceptions.PythonDeprecationWarning
17+
# https://github.com/pytest-dev/pytest-xdist/issues/825#issuecomment-1292450429
18+
ignore:The --rsyncdir command line argument and rsyncdirs config variable are deprecated.:DeprecationWarning
19+
# Pytest warnings
20+
ignore::pytest.PytestUnraisableExceptionWarning
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import warnings
21
from unittest import TestCase
32

3+
import pytest
44
from samtranslator.internal.deprecation_control import deprecated
55

66

@@ -15,12 +15,5 @@ def deprecated_function(x, y):
1515

1616
class TestDeprecationControl(TestCase):
1717
def test_deprecated_decorator(self):
18-
with warnings.catch_warnings(record=True) as w:
18+
with pytest.warns(DeprecationWarning):
1919
deprecated_function(1, 1)
20-
self.assertEqual(len(w), 1)
21-
self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
22-
self.assertIn(
23-
"deprecated_function is deprecated and will be removed in a future release, "
24-
"please use replacement_function",
25-
str(w[-1].message),
26-
)

0 commit comments

Comments
 (0)