ashb commented on code in PR #57853:
URL: https://github.com/apache/airflow/pull/57853#discussion_r2513661327
##########
airflow-core/tests/unit/serialization/test_dag_serialization.py:
##########
@@ -113,15 +113,24 @@ def operator_defaults(overrides):
with operator_defaults({"retries": 2, "retry_delay": 200.0}):
# Test code with modified operator defaults
"""
+ import airflow.sdk.definitions._internal.abstractoperator as
abstract_op_module
from airflow.sdk.bases.operator import OPERATOR_DEFAULTS
original_values = {}
+ original_module_constants = {}
try:
# Store original values and apply overrides
for key, value in overrides.items():
original_values[key] = OPERATOR_DEFAULTS.get(key)
OPERATOR_DEFAULTS[key] = value
+ # Also patch module-level constants like DEFAULT_RETRIES
+ # These are frozen at import time and used as default parameter
values
+ const_name = f"DEFAULT_{key.upper()}"
+ if hasattr(abstract_op_module, const_name):
+ original_module_constants[const_name] =
getattr(abstract_op_module, const_name)
+ setattr(abstract_op_module, const_name, value)
+
Review Comment:
Use the monkeypatch fixture from Pytest - it handles all this for us
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]