Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fail tests on warnings #3248

Merged
merged 16 commits into from
Jul 20, 2023
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),
)