From b5af690a2d97121604afd57c9fa272699e927eaf Mon Sep 17 00:00:00 2001 From: gopidesupavan Date: Tue, 14 Jul 2026 23:54:11 +0100 Subject: [PATCH] Make cheat sheet command test ignore Rich padding changes --- .../cli/commands/test_cheat_sheet_command.py | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/airflow-core/tests/unit/cli/commands/test_cheat_sheet_command.py b/airflow-core/tests/unit/cli/commands/test_cheat_sheet_command.py index b00bb56059304..0ab0cf00b6901 100644 --- a/airflow-core/tests/unit/cli/commands/test_cheat_sheet_command.py +++ b/airflow-core/tests/unit/cli/commands/test_cheat_sheet_command.py @@ -16,6 +16,7 @@ # under the License. from __future__ import annotations +import re from unittest import mock from airflow.cli import cli_parser @@ -72,20 +73,26 @@ def noop(): ] ALL_COMMANDS = """\ -airflow cmd_b | Help text D +airflow cmd_b | Help text D """ SECTION_A = """\ -airflow cmd_a cmd_b | Help text B -airflow cmd_a cmd_c | Help text C +airflow cmd_a cmd_b | Help text B +airflow cmd_a cmd_c | Help text C """ SECTION_E = """\ -airflow cmd_e cmd_f | Help text F -airflow cmd_e cmd_g | Help text G +airflow cmd_e cmd_f | Help text F +airflow cmd_e cmd_g | Help text G """ +def assert_cheat_sheet_rows(output: str, rows: str) -> None: + for row in rows.splitlines(): + command, help_text = row.split(" | ") + assert re.search(rf"^{re.escape(command)}\s+\|\s+{re.escape(help_text)}$", output, re.MULTILINE) + + class TestCheatSheetCommand: @classmethod def setup_class(cls): @@ -97,6 +104,6 @@ def test_should_display_index(self, stdout_capture): args = self.parser.parse_args(["cheat-sheet"]) args.func(args) output = temp_stdout.getvalue() - assert ALL_COMMANDS in output - assert SECTION_A in output - assert SECTION_E in output + assert_cheat_sheet_rows(output, ALL_COMMANDS) + assert_cheat_sheet_rows(output, SECTION_A) + assert_cheat_sheet_rows(output, SECTION_E)