From cb643195cc9712b92d17e1070266dac43a50866e Mon Sep 17 00:00:00 2001 From: Kaxil Naik Date: Mon, 6 May 2024 22:09:49 +0100 Subject: [PATCH] Bump `pytest` to 8.0+ closes https://github.com/apache/airflow/issues/37156 The issues mentioned in the above meta-task are fixed --- dev/breeze/README.md | 2 +- dev/breeze/pyproject.toml | 4 +--- docker_tests/requirements.txt | 4 +--- hatch_build.py | 6 ++---- .../amazon/aws/executors/batch/test_batch_executor.py | 10 ++++------ tests/providers/cncf/kubernetes/test_pod_generator.py | 2 +- tests/utils/log/test_colored_log.py | 8 +++++++- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/dev/breeze/README.md b/dev/breeze/README.md index b9b7b2e15923f..2c38aa7c1a95e 100644 --- a/dev/breeze/README.md +++ b/dev/breeze/README.md @@ -66,6 +66,6 @@ PLEASE DO NOT MODIFY THE HASH BELOW! IT IS AUTOMATICALLY UPDATED BY PRE-COMMIT. --------------------------------------------------------------------------------------------------------- -Package config hash: fdb1d2f95db1e0dba03a84a0854eb69ee931c09845071d69229e02f8ce0ffcca3da51a277a17a517119c3280a4055eee7138a6b2bba34f07f9e941f92578b67b +Package config hash: f8e8729f4236f050d4412cbbc9d53fdd4e6ddad65ce5fafd3c5b6fcdacbea5431eea760b961534a63fd5733b072b38e8167b5b0c12ee48b31c3257306ef11940 --------------------------------------------------------------------------------------------------------- diff --git a/dev/breeze/pyproject.toml b/dev/breeze/pyproject.toml index d84270840c56a..32b3e1fbe6e32 100644 --- a/dev/breeze/pyproject.toml +++ b/dev/breeze/pyproject.toml @@ -63,9 +63,7 @@ dependencies = [ "psutil>=5.9.6", "pygithub>=2.1.1", "pytest-xdist>=3.3.1", - # Temporary upper limmit to <8, not all dependencies at that moment ready to use 8.0 - # Internal meta-task for track https://github.com/apache/airflow/issues/37156 - "pytest>=7.4.4,<8.0", + "pytest>=8.2,<9", "pyyaml>=6.0.1", "requests>=2.31.0", "rich-click>=1.7.1", diff --git a/docker_tests/requirements.txt b/docker_tests/requirements.txt index 60fa7ed9f1478..f4321b3e1e522 100644 --- a/docker_tests/requirements.txt +++ b/docker_tests/requirements.txt @@ -1,6 +1,4 @@ -# Temporary upper limmit to <8, not all dependencies at that moment ready to use 8.0 -# Internal meta-task for track https://github.com/apache/airflow/issues/37156 -pytest>=7.4.4,<8.0 +pytest>=8.2,<9 pytest-xdist # Requests 3 if it will be released, will be heavily breaking. requests>=2.27.0,<3 diff --git a/hatch_build.py b/hatch_build.py index cf2e7cebd1bc4..4e0d74b254eb4 100644 --- a/hatch_build.py +++ b/hatch_build.py @@ -259,7 +259,7 @@ # Coverage 7.4.0 added experimental support for Python 3.12 PEP669 which we use in Airflow "coverage>=7.4.0", "jmespath", - "pytest-asyncio>=0.23.3", + "pytest-asyncio>=0.23.6", "pytest-cov>=4.1.0", "pytest-custom-exit-code>=0.3.0", "pytest-icdiff>=0.9", @@ -268,9 +268,7 @@ "pytest-rerunfailures>=13.0", "pytest-timeouts>=1.2.1", "pytest-xdist>=3.5.0", - # Temporary upper limmit to <8, not all dependencies at that moment ready to use 8.0 - # Internal meta-task for track https://github.com/apache/airflow/issues/37156 - "pytest>=7.4.4,<8.0", + "pytest>=8.2,<9", "requests_mock>=1.11.0", "time-machine>=2.13.0", "wheel>=0.42.0", diff --git a/tests/providers/amazon/aws/executors/batch/test_batch_executor.py b/tests/providers/amazon/aws/executors/batch/test_batch_executor.py index 8a5773bdca90a..e814340d2d4ea 100644 --- a/tests/providers/amazon/aws/executors/batch/test_batch_executor.py +++ b/tests/providers/amazon/aws/executors/batch/test_batch_executor.py @@ -56,6 +56,7 @@ def set_env_vars(): (CONFIG_GROUP_NAME, AllBatchConfigKeys.JOB_QUEUE): "some-job-queue", (CONFIG_GROUP_NAME, AllBatchConfigKeys.JOB_DEFINITION): "some-job-def", (CONFIG_GROUP_NAME, AllBatchConfigKeys.MAX_SUBMIT_JOB_ATTEMPTS): "3", + (CONFIG_GROUP_NAME, AllBatchConfigKeys.CHECK_HEALTH_ON_STARTUP): "True", } with conf_vars(overrides): yield @@ -510,15 +511,12 @@ def test_start_success(self, set_env_vars, caplog): batch_mock.describe_jobs.return_value = {} executor.batch = batch_mock - caplog.set_level(logging.DEBUG) - - executor.start() + caplog.clear() + with caplog.at_level(logging.DEBUG): + executor.start() assert "succeeded" in caplog.text - @mock.patch( - "airflow.providers.amazon.aws.executors.batch.boto_schema.BatchDescribeJobsResponseSchema.load" - ) def test_health_check_failure(self, mock_executor, set_env_vars): mock_executor.batch.describe_jobs.side_effect = Exception("Test_failure") executor = AwsBatchExecutor() diff --git a/tests/providers/cncf/kubernetes/test_pod_generator.py b/tests/providers/cncf/kubernetes/test_pod_generator.py index 28c4323cbceb7..27d4ef9c862fd 100644 --- a/tests/providers/cncf/kubernetes/test_pod_generator.py +++ b/tests/providers/cncf/kubernetes/test_pod_generator.py @@ -170,7 +170,7 @@ def test_gen_pod_extract_xcom(self, mock_rand_str, data_file): template_file = data_file("pods/generator_base_with_secrets.yaml").as_posix() pod_generator = PodGenerator(pod_template_file=template_file, extract_xcom=True) - with pytest.warns(AirflowProviderDeprecationWarning, match="deprecated and will be removed"): + with pytest.warns(AirflowProviderDeprecationWarning): result = pod_generator.gen_pod() container_two = { "name": "airflow-xcom-sidecar", diff --git a/tests/utils/log/test_colored_log.py b/tests/utils/log/test_colored_log.py index e90029361f67c..1eb86868caaa4 100644 --- a/tests/utils/log/test_colored_log.py +++ b/tests/utils/log/test_colored_log.py @@ -22,6 +22,7 @@ import pytest +from airflow.configuration import conf from airflow.utils.log.colored_log import CustomTTYColoredFormatter pytestmark = pytest.mark.db_test @@ -32,7 +33,12 @@ def test_format_time_uses_tz_aware(mock_fmt): # get a logger that uses CustomTTYColoredFormatter logger = logging.getLogger("test_format_time") h = logging.StreamHandler() - h.setFormatter(CustomTTYColoredFormatter()) + + # Explicitly pass fmt to CustomTTYColoredFormatter to avoid side effects + # from the default value being changed by other tests. + # Previously, it was being affected by tests/models/test_trigger.py::test_assign_unassigned + log_fmt = conf.get("logging", "log_format") + h.setFormatter(CustomTTYColoredFormatter(fmt=log_fmt)) logger.addHandler(h) # verify that it uses TimezoneAware.formatTime