Skip to content

Commit

Permalink
ci: fail tests on warnings (#3248)
Browse files Browse the repository at this point in the history
Co-authored-by: Slava Senchenko <sencslav@amazon.com>
  • Loading branch information
hoffa and ssenchenko committed Jul 20, 2023
1 parent 8b9e24f commit dc5a43f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
11 changes: 11 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@ markers =
slow: marks tests as slow (deselect with '-m "not slow"')
log_cli = 1
log_cli_level = INFO
filterwarnings =
error
# From our own tests
ignore:__init__ is deprecated and will be removed in a future release:DeprecationWarning
ignore:deprecated_function is deprecated and will be removed in a future release, please use replacement_function:DeprecationWarning
# Python 3.7 deprecation
ignore::boto3.exceptions.PythonDeprecationWarning
# https://github.com/pytest-dev/pytest-xdist/issues/825#issuecomment-1292450429
ignore:The --rsyncdir command line argument and rsyncdirs config variable are deprecated.:DeprecationWarning
# Pytest warnings
ignore::pytest.PytestUnraisableExceptionWarning
11 changes: 2 additions & 9 deletions tests/internal/test_deprecation_control.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import warnings
from unittest import TestCase

import pytest
from samtranslator.internal.deprecation_control import deprecated


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

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

0 comments on commit dc5a43f

Please sign in to comment.