diff --git a/awx/main/tests/conftest.py b/awx/main/tests/conftest.py index 4cf63bc8ad..ed4acd4b48 100644 --- a/awx/main/tests/conftest.py +++ b/awx/main/tests/conftest.py @@ -14,6 +14,8 @@ from awx.main.tests.factories import ( create_workflow_job_template, ) +from django.core.cache import cache + def pytest_addoption(parser): parser.addoption( @@ -130,3 +132,10 @@ def mock_cache(): return MockCache() + +def pytest_runtest_teardown(item, nextitem): + # clear Django cache at the end of every test ran + # NOTE: this should not be memcache, see test_cache in test_env.py + # this is a local test cache, so we want every test to start with empty cache + cache.clear() + diff --git a/awx/main/tests/functional/api/test_settings.py b/awx/main/tests/functional/api/test_settings.py index e21f0a9a06..de38f3ce54 100644 --- a/awx/main/tests/functional/api/test_settings.py +++ b/awx/main/tests/functional/api/test_settings.py @@ -75,9 +75,11 @@ def test_awx_task_env_validity(get, patch, admin, value, expected): url = reverse('api:setting_singleton_detail', kwargs={'category_slug': 'jobs'}) patch(url, user=admin, data={'AWX_TASK_ENV': value}, expect=expected) + resp = get(url, user=admin) if expected == 200: - resp = get(url, user=admin) assert resp.data['AWX_TASK_ENV'] == dict((k, str(v)) for k, v in value.items()) + else: + assert resp.data['AWX_TASK_ENV'] == dict() @pytest.mark.django_db