You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ep...@apache.org on 2022/11/09 14:35:22 UTC

[airflow] 17/29: fIx failing masking tests for python < 3.10 (#27337)

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

ephraimanierobi pushed a commit to branch v2-4-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 1b4697ac076fe5b241ff8dd16e5b1139b92fb231
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Fri Oct 28 09:36:27 2022 +0200

    fIx failing masking tests for python < 3.10 (#27337)
    
    Seems that the number of times user is printed in stack trace
    depend on Python version. The fix in #27335 seems to only have
    worked for Python 3.10 with the 1.0.0 of exceptiongroup the
    stack trace has less stack levels.
    
    (cherry picked from commit fcec804ff513d8f148d5069a48e7adf703855a96)
---
 setup.py                               |  2 +-
 tests/utils/log/test_secrets_masker.py | 27 ++-------------------------
 2 files changed, 3 insertions(+), 26 deletions(-)

diff --git a/setup.py b/setup.py
index d1eea7e550..8d1b19af1d 100644
--- a/setup.py
+++ b/setup.py
@@ -202,7 +202,7 @@ def write_version(filename: str = str(AIRFLOW_SOURCES_ROOT / "airflow" / "git_ve
     """
     Write the Semver version + git hash to file, e.g. ".dev0+2f635dc265e78db6708f59f68e8009abb92c1e65".
 
-    :param str filename: Destination file to write
+    :param str filename: Destination file to write.
     """
     text = f"{git_version(version)}"
     with open(filename, 'w') as file:
diff --git a/tests/utils/log/test_secrets_masker.py b/tests/utils/log/test_secrets_masker.py
index 6de30eb574..edc516f04a 100644
--- a/tests/utils/log/test_secrets_masker.py
+++ b/tests/utils/log/test_secrets_masker.py
@@ -169,31 +169,8 @@ class TestSecretsMasker:
         except RuntimeError:
             logger.exception("Err")
 
-        line = lineno() - 8
-
-        assert caplog.text == textwrap.dedent(
-            f"""\
-            ERROR Err
-            Traceback (most recent call last):
-              File ".../test_secrets_masker.py", line {line}, in test_masking_in_implicit_context_exceptions
-                raise RuntimeError(f"Cannot connect to user:{{p}}")
-            RuntimeError: Cannot connect to user:***
-
-            During handling of the above exception, another exception occurred:
-
-            Traceback (most recent call last):
-              File ".../test_secrets_masker.py", line {line+2}, in test_masking_in_implicit_context_exceptions
-                raise RuntimeError(f'Exception: {{ex1}}')
-            RuntimeError: Exception: Cannot connect to user:***
-
-            During handling of the above exception, another exception occurred:
-
-            Traceback (most recent call last):
-              File ".../test_secrets_masker.py", line {line+4}, in test_masking_in_implicit_context_exceptions
-                raise RuntimeError(f'Exception: {{ex2}}')
-            RuntimeError: Exception: Exception: Cannot connect to user:***
-            """
-        )
+        assert "user:password" not in caplog.text
+        assert caplog.text.count("user:***") >= 2
 
     def test_masking_in_explicit_context_exceptions(self, logger, caplog):
         """