Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix running debuggers inside airflow tasks test #26806

Merged
merged 1 commit into from Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions airflow/utils/log/secrets_masker.py
Expand Up @@ -271,6 +271,7 @@ class RedactedIO(TextIO):

def __init__(self):
self.target = sys.stdout
self.fileno = sys.stdout.fileno

def write(self, s: str) -> int:
s = redact(s)
Expand Down
12 changes: 12 additions & 0 deletions tests/utils/log/test_secrets_masker.py
Expand Up @@ -18,9 +18,11 @@

import contextlib
import inspect
import io
import logging
import logging.config
import os
import sys
import textwrap

import pytest
Expand Down Expand Up @@ -363,3 +365,13 @@ def test_write(self, capsys):
RedactedIO().write(p)
stdout = capsys.readouterr().out
assert stdout == "***"

def test_input_builtin(self, monkeypatch):
"""
Test that when redirect is inplace the `input()` builtin works.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Test that when redirect is inplace the `input()` builtin works.
Test that when redirect is in place the `input()` builtin works.


This is used by debuggers!
"""
monkeypatch.setattr(sys, 'stdin', io.StringIO("a\n"))
with contextlib.redirect_stdout(RedactedIO()):
assert input() == "a"