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 2201154252 Fix long-standing side-effect of test replacing formatter
(#39853)
2201154252 is described below
commit 2201154252d589cb7d037c3d3381c229253568f3
Author: Jarek Potiuk <[email protected]>
AuthorDate: Sun May 26 19:48:49 2024 +0200
Fix long-standing side-effect of test replacing formatter (#39853)
There was a long-standing test that had a side-effect of replacing
formatter and recently it started to fail in PRs.
This PR patches the formatter only for time of the tests.
---
tests/utils/log/test_secrets_masker.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tests/utils/log/test_secrets_masker.py
b/tests/utils/log/test_secrets_masker.py
index c5f9c184f2..5781139677 100644
--- a/tests/utils/log/test_secrets_masker.py
+++ b/tests/utils/log/test_secrets_masker.py
@@ -94,10 +94,12 @@ class TestSecretsMasker:
assert caplog.text == "INFO Cannot connect to user:***\n"
def test_extra(self, logger, caplog):
- logger.handlers[0].formatter = ShortExcFormatter("%(levelname)s
%(message)s %(conn)s")
- logger.info("Cannot connect", extra={"conn": "user:password"})
+ with patch.object(
+ logger.handlers[0], "formatter", ShortExcFormatter("%(levelname)s
%(message)s %(conn)s")
+ ):
+ logger.info("Cannot connect", extra={"conn": "user:password"})
- assert caplog.text == "INFO Cannot connect user:***\n"
+ assert caplog.text == "INFO Cannot connect user:***\n"
def test_exception(self, logger, caplog):
try: