diff --git a/openstack_dashboard/dashboards/settings/user/tests.py b/openstack_dashboard/dashboards/settings/user/tests.py index 54c49424d5..d5284add08 100644 --- a/openstack_dashboard/dashboards/settings/user/tests.py +++ b/openstack_dashboard/dashboards/settings/user/tests.py @@ -12,7 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -from django.conf import settings from django.urls import reverse from openstack_dashboard.test import helpers as test @@ -32,9 +31,13 @@ class UserSettingsTest(test.TestCase): def test_display_language(self): # Add an unknown language to LANGUAGES list - settings.LANGUAGES += (('unknown', 'Unknown Language'),) + with self.modify_settings( + # NOTE: modify_settings take a list of values to append. + # We add a single entry but it is a tuple, + # so we need to wrap it as a list. + LANGUAGES={'append': [('unknown', 'Unknown Language')]}): + res = self.client.get(INDEX_URL) - res = self.client.get(INDEX_URL) # Known language self.assertContains(res, 'English') # Unknown language diff --git a/openstack_dashboard/test/unit/api/test_base.py b/openstack_dashboard/test/unit/api/test_base.py index b3ba74d581..443e684c18 100644 --- a/openstack_dashboard/test/unit/api/test_base.py +++ b/openstack_dashboard/test/unit/api/test_base.py @@ -16,8 +16,6 @@ # License for the specific language governing permissions and limitations # under the License. -from django.conf import settings - from horizon import exceptions from openstack_dashboard.api import base as api_base @@ -232,21 +230,22 @@ class ApiVersionTests(test.TestCase): def setUp(self): super(ApiVersionTests, self).setUp() - self.previous_settings = settings.OPENSTACK_API_VERSIONS - settings.OPENSTACK_API_VERSIONS = { - "data-processing": 1.1, - "identity": "3", - "volume": 1 - } - # Make sure cached data from other tests doesn't interfere - cinder.VERSIONS.clear_active_cache() - keystone.VERSIONS.clear_active_cache() - glance.VERSIONS.clear_active_cache() + override = self.settings( + OPENSTACK_API_VERSIONS={ + "data-processing": 1.1, + "identity": "3", + "volume": 1 + } + ) + override.enable() + self.addCleanup(override.disable) - def tearDown(self): - super(ApiVersionTests, self).tearDown() - settings.OPENSTACK_API_VERSIONS = self.previous_settings + # Make sure cached data from other tests doesn't interfere + self._clear_version_cache() # Clear out our bogus data so it doesn't interfere + self.addCleanup(self._clear_version_cache) + + def _clear_version_cache(self): cinder.VERSIONS.clear_active_cache() keystone.VERSIONS.clear_active_cache() glance.VERSIONS.clear_active_cache()