Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions airflow-core/src/airflow/cli/commands/info_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,11 @@ def show(self, output: str, console: AirflowConsole | None = None) -> None:

def render_text(self, output: str) -> str:
"""Export the info to string."""
console = AirflowConsole(record=True)
with console.capture():
# The text is uploaded as a file: no escape codes, fixed width regardless of the terminal.
console = AirflowConsole(color_system=None, width=200)
with console.capture() as capture:
self.show(output=output, console=console)
return console.export_text()
return capture.get()


class FileIoException(Exception):
Expand Down
10 changes: 10 additions & 0 deletions airflow-core/tests/unit/cli/commands/test_info_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ def test_show_info_anonymize(self, stdout_capture):
assert airflow_version in output
assert "postgresql+psycopg2://p...s:PASSWORD@postgres/airflow" in output

@mock.patch.dict(os.environ, {"FORCE_COLOR": "1", "TERM": "xterm-256color"})
def test_render_text_stays_plain_on_a_color_terminal(self):
instance = info_command.AirflowInfo(info_command.NullAnonymizer())

rendered = instance.render_text("table")

assert airflow_version in rendered
assert "\x1b[" not in rendered


@pytest.fixture
def setup_parser():
Expand All @@ -188,3 +197,4 @@ def test_show_info_anonymize_fileio(self, setup_parser, cleanup_providers_manage
with stdout_capture as stdout:
info_command.show_info(setup_parser.parse_args(["info", "--file-io", "--anonymize"]))
assert "https://file.io/TEST" in stdout.getvalue()
assert airflow_version in post.call_args.kwargs["content"]
Loading