You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2026/04/21 12:34:55 UTC

(airflow) branch main updated: Make werkzeug import optional in Google provider test conftest (#65581)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new cc1c56c269f Make werkzeug import optional in Google provider test conftest (#65581)
cc1c56c269f is described below

commit cc1c56c269f3af3a96a204cbbec201e9aed767df
Author: Shahar Epstein <60...@users.noreply.github.com>
AuthorDate: Tue Apr 21 15:34:47 2026 +0300

    Make werkzeug import optional in Google provider test conftest (#65581)
    
    The werkzeug import was added to Google provider's test conftest during
    the FAB connexion-to-FastAPI migration (PR #62664, commit f4fd68fb15),
    but it's not actually needed for most Google provider tests.
    
    Only 1 test file (test_google_openid.py) uses Flask test client which
    requires werkzeug. The other 99%+ of Google provider tests don't need
    werkzeug at all, yet the hard import was causing test collection failures
    when werkzeug wasn't installed.
    
    This change makes the werkzeug import optional with a try/except block,
    allowing tests that don't need Flask/werkzeug to run without this
    dependency. Tests that do need werkzeug (like test_google_openid.py)
    will still work when werkzeug is available.
    
    Note: werkzeug was never part of Google provider in Airflow 2.X era.
    This unnecessary hard dependency was introduced in March 2026 as part
    of a blanket change that was appropriate for FAB provider but not for
    Google provider.
---
 providers/google/tests/conftest.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/providers/google/tests/conftest.py b/providers/google/tests/conftest.py
index 1cae3e67b64..5f77d2be05b 100644
--- a/providers/google/tests/conftest.py
+++ b/providers/google/tests/conftest.py
@@ -20,11 +20,14 @@ from __future__ import annotations
 
 import importlib.metadata
 
-import werkzeug
+try:
+    import werkzeug
+except ModuleNotFoundError:
+    werkzeug = None
 
 pytest_plugins = "tests_common.pytest_plugin"
 
 # Flask 2.2.x test client reads werkzeug.__version__ which Werkzeug 3.x removed.
 # Connexion 2.x used to pin Werkzeug<3, but connexion is now removed from FAB provider.
-if not hasattr(werkzeug, "__version__"):
+if werkzeug is not None and not hasattr(werkzeug, "__version__"):
     werkzeug.__version__ = importlib.metadata.version("werkzeug")