From b0dd6eaf1e8790d1b7caab406a14fab9d8aa4f2c Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Fri, 26 Jan 2024 16:18:58 -0800 Subject: [PATCH] try remove color errors in git CI --- django_typer/tests/tests.py | 50 ++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/django_typer/tests/tests.py b/django_typer/tests/tests.py index 26b435d..a993896 100644 --- a/django_typer/tests/tests.py +++ b/django_typer/tests/tests.py @@ -38,6 +38,30 @@ def similarity(text1, text2): TESTS_DIR = Path(__file__).parent +class NoColorMixin: + + default_color_system: str + + def setUp(self): + # colors in terminal output screw up github CI runs - todo less intrusive + # way around this?? + try: + from typer import rich_utils + self.default_color_system = rich_utils.COLOR_SYSTEM + rich_utils.COLOR_SYSTEM = None + except ImportError: + pass + return super().setUp() + + def tearDown(self): + try: + from typer import rich_utils + rich_utils.COLOR_SYSTEM = self.default_color_system + except ImportError: + pass + return super().tearDown() + + def get_named_arguments(function): sig = inspect.signature(function) return [ @@ -684,7 +708,8 @@ def test_verbosity(self): self.assertEqual(read_django_parameters().get("verbosity", None), 0) -class TestHelpPrecedence(TestCase): +class TestHelpPrecedence(NoColorMixin, TestCase): + def test_help_precedence1(self): buffer = StringIO() cmd = get_command("help_precedence1", stdout=buffer) @@ -758,33 +783,12 @@ def test_help_precedence6(self): ) -class TestGroups(TestCase): +class TestGroups(NoColorMixin, TestCase): """ A collection of tests that test complex grouping commands and also that command inheritance behaves as expected. """ - default_color_system: str - - def setUp(self) -> None: - # colors in terminal output screw up github CI runs - todo less intrusive - # way around this?? - try: - from typer import rich_utils - self.default_color_system = rich_utils.COLOR_SYSTEM - rich_utils.COLOR_SYSTEM = None - except ImportError: - pass - return super().setUp() - - def tearDown(self) -> None: - try: - from typer import rich_utils - rich_utils.COLOR_SYSTEM = self.default_color_system - except ImportError: - pass - return super().tearDown() - def test_group_call(self): with self.assertRaises(NotImplementedError): get_command("groups")()