tests: Enable UserWarning by default

These nearly always indicate a more serious issue that we need to
address. Make them an error, correcting one issue this highlights.

Change-Id: I9452a4f8ac6bcd35c803e591a1022294041d26a0
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-05-25 16:55:02 +01:00
parent dcd89705d6
commit de6b6bce02
2 changed files with 8 additions and 3 deletions

View File

@ -34,6 +34,9 @@ class WarningsFixture(fixtures.Fixture):
self._original_warning_filters = warnings.filters[:]
# enable user warnings as many libraries use this (it's the default)
warnings.simplefilter("error", UserWarning)
# enable deprecation warnings in general...
warnings.simplefilter("once", DeprecationWarning)

View File

@ -14,6 +14,7 @@ import copy
import queue
from unittest import mock
from keystoneauth1 import session
from testscenarios import load_tests_apply_scenarios as load_tests # noqa
from openstack import exceptions
@ -622,7 +623,7 @@ class TestProxyCache(base.TestCase):
cloud_config_fixture='clouds_cache.yaml'
)
self.session = mock.Mock()
self.session = mock.Mock(spec=session.Session)
self.session._sdk_connection = self.cloud
self.session.get_project_id = mock.Mock(return_value='fake_prj')
@ -651,10 +652,11 @@ class TestProxyCache(base.TestCase):
connect_retries=mock.ANY,
raise_exc=mock.ANY,
global_request_id=mock.ANY,
endpoint_filter=mock.ANY,
headers=mock.ANY,
microversion=mock.ANY,
params=mock.ANY,
endpoint_filter=mock.ANY,
headers=mock.ANY,
rate_semaphore=mock.ANY,
)
self.assertIn(self._get_key(1), self.cloud._api_cache_keys)