xBis7 commented on code in PR #56187:
URL: https://github.com/apache/airflow/pull/56187#discussion_r2588294689


##########
airflow-core/tests/unit/observability/metrics/test_stats.py:
##########
@@ -169,11 +176,37 @@ def 
test_load_allow_and_block_list_validator_loads_only_allow_list_validator(sel
                 ("metrics", "metrics_block_list"): "name1,name2",
             }
         ):
-            importlib.reload(airflow.stats)
-            assert type(airflow.stats.Stats.metrics_validator) is 
PatternAllowListValidator
-            assert airflow.stats.Stats.metrics_validator.validate_list == 
("name1", "name2")
+            importlib.reload(airflow.observability.stats)
+            assert type(airflow.observability.stats.Stats.metrics_validator) 
is PatternAllowListValidator
+            assert 
airflow.observability.stats.Stats.metrics_validator.validate_list == (
+                "name1",
+                "name2",
+            )
         # Avoid side-effects
-        importlib.reload(airflow.stats)
+        importlib.reload(airflow.observability.stats)
+
+    def test_deprecation_warning_for_old_path(self):
+        # TODO: remove this test once the deprecation warning is removed.
+        import warnings
+
+        from airflow.observability.stats import Stats
+        from airflow.utils.deprecation_tools import DeprecatedImportWarning
+
+        # Clear any cached value.
+        airflow.__dict__.pop("Stats", None)
+
+        # Old path should warn.
+        warning_pattern = "Import 'Stats' directly from the airflow module is 
deprecated"
+        with pytest.warns(DeprecatedImportWarning, match=warning_pattern):
+            assert getattr(airflow, "Stats") is Stats
+
+        # Clear cache again.
+        airflow.__dict__.pop("Stats", None)
+
+        # There shouldn't be a warning.
+        with warnings.catch_warnings():
+            warnings.simplefilter("error", DeprecatedImportWarning)
+            assert getattr(airflow.observability.stats, "Stats") is Stats

Review Comment:
   It was mostly for convincing myself that it works. I removed it.



-- 
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]

Reply via email to