summaryrefslogtreecommitdiffstats
path: root/awx_collection
diff options
context:
space:
mode:
authorSviatoslav Sydorenko <wk@sydorenko.org.ua>2024-11-07 13:19:08 +0100
committerAlan Rominger <arominge@redhat.com>2024-11-25 20:01:21 +0100
commitd8e87da898590e174f8fc0d70d2cb32f29d0c546 (patch)
tree5c5626a8e2eeae88caa88f63fdb0d114afbf1744 /awx_collection
parentAdd descriptions for plugin names (#15643) (diff)
downloadawx-d8e87da898590e174f8fc0d70d2cb32f29d0c546.tar.xz
awx-d8e87da898590e174f8fc0d70d2cb32f29d0c546.zip
🧪 Make pytest notify us about future warnings
In essence, this configures Python to turn any warnings emitted in runtime into errors[[1]]. This is the best practice that allows reacting to future deprecation announcements that are coming from the dependencies (direct, or transitive, or even CPython itself)[[2]]. The typical workflow looks like this: 1. If a dependency is updated an a warning is hit in tests, the deprecated thing should be replaced with newer APIs. 2. If a dependency is transitive or we have no control over it otherwise, the specific warning and a regex matching its message, plus the module reference (where possible) can be added to the list of temporary ignores in `pytest.ini`. 3. The list of temporary ignores should be reevaluated periodically, including when dependency re-pinning in lockfile is happening. [1]: https://docs.python.org/3/using/cmdline.html#cmdoption-W [2]: https://pytest-with-eric.com/configuration/pytest-ignore-warnings/
Diffstat (limited to 'awx_collection')
-rw-r--r--awx_collection/test/awx/test_instance.py6
-rw-r--r--awx_collection/test/awx/test_instance_group.py12
-rw-r--r--awx_collection/test/awx/test_workflow_job_template_node.py8
3 files changed, 26 insertions, 0 deletions
diff --git a/awx_collection/test/awx/test_instance.py b/awx_collection/test/awx/test_instance.py
index 06d1fe94bd..ccc643d293 100644
--- a/awx_collection/test/awx/test_instance.py
+++ b/awx_collection/test/awx/test_instance.py
@@ -8,6 +8,12 @@ from awx.main.models import Instance
from django.test.utils import override_settings
+@pytest.mark.filterwarnings(
+ # FIXME: Figure out where it is emited and what causes it.
+ # FIXME: The suppression should be made more specific or the cause fixed.
+ # Ref: https://github.com/ansible/awx/pull/15620
+ "ignore::RuntimeWarning",
+)
@pytest.mark.django_db
def test_peers_adding_and_removing(run_module, admin_user):
with override_settings(IS_K8S=True):
diff --git a/awx_collection/test/awx/test_instance_group.py b/awx_collection/test/awx/test_instance_group.py
index 91dc174c05..86de7f5fd5 100644
--- a/awx_collection/test/awx/test_instance_group.py
+++ b/awx_collection/test/awx/test_instance_group.py
@@ -7,6 +7,12 @@ import pytest
from awx.main.models import InstanceGroup, Instance
+@pytest.mark.filterwarnings(
+ # FIXME: Figure out where it is emited and what causes it.
+ # FIXME: The suppression should be made more specific or the cause fixed.
+ # Ref: https://github.com/ansible/awx/pull/15620
+ "ignore::RuntimeWarning",
+)
@pytest.mark.django_db
def test_instance_group_create(run_module, admin_user):
result = run_module(
@@ -36,6 +42,12 @@ def test_instance_group_create(run_module, admin_user):
assert len(all_instance_names) == 1, 'Too many instances in group {0}'.format(','.join(all_instance_names))
+@pytest.mark.filterwarnings(
+ # FIXME: Figure out where it is emited and what causes it.
+ # FIXME: The suppression should be made more specific or the cause fixed.
+ # Ref: https://github.com/ansible/awx/pull/15620
+ "ignore::RuntimeWarning",
+)
@pytest.mark.django_db
def test_container_group_create(run_module, admin_user, kube_credential):
pod_spec = "{ 'Nothing': True }"
diff --git a/awx_collection/test/awx/test_workflow_job_template_node.py b/awx_collection/test/awx/test_workflow_job_template_node.py
index a4bc56a8f2..44855ecc69 100644
--- a/awx_collection/test/awx/test_workflow_job_template_node.py
+++ b/awx_collection/test/awx/test_workflow_job_template_node.py
@@ -8,6 +8,14 @@ import pytest
from awx.main.models import WorkflowJobTemplateNode, WorkflowJobTemplate, JobTemplate, UnifiedJobTemplate
+pytestmark = pytest.mark.filterwarnings(
+ # FIXME: Figure out where it is emited and what causes it.
+ # FIXME: The suppression should be made more specific or the cause fixed.
+ # Ref: https://github.com/ansible/awx/pull/15620
+ "ignore::RuntimeWarning",
+)
+
+
@pytest.fixture
def job_template(project, inventory):
return JobTemplate.objects.create(