From e3d1644179a7704ef406834937ba372bf553c7f4 Mon Sep 17 00:00:00 2001 From: Shahar Epstein <60007259+shahar1@users.noreply.github.com> Date: Sat, 13 Jun 2026 15:49:05 +0300 Subject: [PATCH] Remove redundant tests in airflow-core MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Surfaced by two detectors (per-test coverage signatures + an AST whole-tree scan) and confirmed by reading each body, its decorators and the production code. Exact / near-exact duplicates (P5): - test_base_executor.py::test_state_generic — byte-identical to test_state_queued. - test_base_executor.py::TestCallbackSupport::test_local_executor_supports_callbacks_true — cross-file dup of test_local_executor.py's TestLocalExecutorCallbackSupport; LocalExecutor's flag belongs there. - test_base_job.py::test_base_job_respects_plugin_hooks — byte-identical to test_state_sysexit; tests nothing about plugin hooks (real coverage is test_base_job_respects_plugin_lifecycle). - test_kerberos_command.py::test_run_command_with_mode_standard — byte-identical to test_run_command; both assert the STANDARD default. - test_logging_config.py::test_empty_string_falls_back_to_default — subsumed by test_falsy_logging_class_path_falls_back_to_default, parametrized over ['', None]. Library-behaviour tests (P1) — attrs-generated dunders, no custom logic: - test_rollup_wait_policy.py::TestRepr (both repr tests) and test_wait_for_all_is_stateless exercise @attrs.define(frozen=True) __repr__/__eq__/ __hash__ on WaitForAll/MinimumCount, which define no custom dunders. --- .../unit/cli/commands/test_kerberos_command.py | 10 ---------- .../tests/unit/executors/test_base_executor.py | 15 --------------- airflow-core/tests/unit/jobs/test_base_job.py | 10 ---------- .../tests/unit/logging/test_logging_config.py | 8 -------- .../test_rollup_wait_policy.py | 17 ----------------- 5 files changed, 60 deletions(-) diff --git a/airflow-core/tests/unit/cli/commands/test_kerberos_command.py b/airflow-core/tests/unit/cli/commands/test_kerberos_command.py index ac8ba911ddab7..3fc5a822a7696 100644 --- a/airflow-core/tests/unit/cli/commands/test_kerberos_command.py +++ b/airflow-core/tests/unit/cli/commands/test_kerberos_command.py @@ -119,16 +119,6 @@ def test_run_command_daemon(self, mock_krb, mock_daemon, mock_setup_locations, m *python_3_13_close_calls, ] - @mock.patch("airflow.cli.commands.kerberos_command.krb") - @conf_vars({("core", "executor"): "CeleryExecutor"}) - def test_run_command_with_mode_standard(self, mock_krb): - args = self.parser.parse_args(["kerberos", "PRINCIPAL", "--keytab", "/tmp/airflow.keytab"]) - - kerberos_command.kerberos(args) - mock_krb.run.assert_called_once_with( - keytab="/tmp/airflow.keytab", principal="PRINCIPAL", mode=KerberosMode.STANDARD - ) - @mock.patch("airflow.cli.commands.kerberos_command.krb") @conf_vars({("core", "executor"): "CeleryExecutor"}) def test_run_command_with_mode_one_time(self, mock_krb): diff --git a/airflow-core/tests/unit/executors/test_base_executor.py b/airflow-core/tests/unit/executors/test_base_executor.py index 9c45c5056cae5..f74d1f1e08464 100644 --- a/airflow-core/tests/unit/executors/test_base_executor.py +++ b/airflow-core/tests/unit/executors/test_base_executor.py @@ -445,16 +445,6 @@ def test_state_queued(): assert executor.event_buffer[key] == (TaskInstanceState.QUEUED, info) -def test_state_generic(): - executor = BaseExecutor() - key = TaskInstanceKey("my_dag1", "my_task1", timezone.utcnow(), 1) - executor.running.add(key) - info = "info" - executor.queued(key, info=info) - assert not executor.running - assert executor.event_buffer[key] == (TaskInstanceState.QUEUED, info) - - def test_state_running(): executor = BaseExecutor() key = TaskInstanceKey("my_dag1", "my_task1", timezone.utcnow(), 1) @@ -649,11 +639,6 @@ def test_supports_callbacks_flag_default_false(self): executor = BaseExecutor() assert executor.supports_callbacks is False - def test_local_executor_supports_callbacks_true(self): - """Test that LocalExecutor sets supports_callbacks to True.""" - executor = LocalExecutor() - assert executor.supports_callbacks is True - @pytest.mark.db_test def test_queue_callback_without_support_raises_error(self, dag_maker, session): executor = BaseExecutor() # supports_callbacks = False by default diff --git a/airflow-core/tests/unit/jobs/test_base_job.py b/airflow-core/tests/unit/jobs/test_base_job.py index a38956c61bd5a..211e4128d01de 100644 --- a/airflow-core/tests/unit/jobs/test_base_job.py +++ b/airflow-core/tests/unit/jobs/test_base_job.py @@ -56,16 +56,6 @@ def test_state_sysexit(self): assert job.state == State.SUCCESS assert job.end_date is not None - def test_base_job_respects_plugin_hooks(self): - import sys - - job = Job() - job_runner = MockJobRunner(job=job, func=lambda: sys.exit(0)) - run_job(job=job, execute_callable=job_runner._execute) - - assert job.state == State.SUCCESS - assert job.end_date is not None - def test_base_job_respects_plugin_lifecycle(self, dag_maker, listener_manager): """ Test if DagRun is successful, and if Success callbacks is defined, it is sent to DagFileProcessor. diff --git a/airflow-core/tests/unit/logging/test_logging_config.py b/airflow-core/tests/unit/logging/test_logging_config.py index 04449a6741978..3fffb376425b9 100644 --- a/airflow-core/tests/unit/logging/test_logging_config.py +++ b/airflow-core/tests/unit/logging/test_logging_config.py @@ -57,14 +57,6 @@ def test_user_defined_dict_is_imported(self, monkeypatch): config = _get_logging_config() assert config is custom - def test_empty_string_falls_back_to_default(self): - from airflow.config_templates.airflow_local_settings import DEFAULT_LOGGING_CONFIG - - with mock.patch("airflow.logging_config.conf") as mocked_conf: - mocked_conf.get.return_value = "" - config = _get_logging_config() - assert config == DEFAULT_LOGGING_CONFIG - @pytest.mark.parametrize( "logging_class_path", [pytest.param("", id="empty-string"), pytest.param(None, id="none")], diff --git a/airflow-core/tests/unit/partition_mappers/test_rollup_wait_policy.py b/airflow-core/tests/unit/partition_mappers/test_rollup_wait_policy.py index e5033322ddb18..e2405675c0fcd 100644 --- a/airflow-core/tests/unit/partition_mappers/test_rollup_wait_policy.py +++ b/airflow-core/tests/unit/partition_mappers/test_rollup_wait_policy.py @@ -50,14 +50,6 @@ def test_minimum_count_zero_rejected(self): def test_minimum_count_stores_n(self, n): assert MinimumCount(n).n == n - def test_wait_for_all_is_stateless(self): - a = WaitForAll() - b = WaitForAll() - assert type(a) is WaitForAll - assert type(b) is WaitForAll - assert a == b - assert hash(a) == hash(b) - def test_default_wait_policy_is_wait_for_all_instance(self, make_mapper): mapper = make_mapper() assert isinstance(mapper.wait_policy, WaitForAll) @@ -113,15 +105,6 @@ def test_is_unreachable(self, policy, expected, unreachable): assert policy.is_unreachable(expected) is unreachable -class TestRepr: - def test_wait_for_all_repr(self): - assert repr(WaitForAll()) == "WaitForAll()" - - def test_minimum_count_repr(self): - assert repr(MinimumCount(5)) == "MinimumCount(n=5)" - assert repr(MinimumCount(-3)) == "MinimumCount(n=-3)" - - class TestSerializeRoundTrip: @pytest.mark.parametrize( "policy",