From cf5772f2368f2c4a27b7ebe21428dbae1b7ce987 Mon Sep 17 00:00:00 2001 From: Abhishek-kumar-samsung Date: Fri, 3 Feb 2023 17:52:03 +0530 Subject: [PATCH 1/3] migrating from unittest to pytest tests cli file --- tests/cli/commands/test_pool_command.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/cli/commands/test_pool_command.py b/tests/cli/commands/test_pool_command.py index 96809fb4df712..5350d086fb910 100644 --- a/tests/cli/commands/test_pool_command.py +++ b/tests/cli/commands/test_pool_command.py @@ -20,7 +20,6 @@ import io import json import os -import unittest from contextlib import redirect_stdout import pytest @@ -33,17 +32,15 @@ from airflow.utils.db import add_default_pool_if_not_exists -class TestCliPools(unittest.TestCase): +class TestCliPools: @classmethod - def setUpClass(cls): + def setup_class(cls): cls.dagbag = models.DagBag(include_examples=True) cls.parser = cli_parser.get_parser() - - def setUp(self): - super().setUp() settings.configure_orm() - self.session = Session - self._cleanup() + cls.session = Session + cls._cleanup() + def tearDown(self): self._cleanup() From 59a5a32cfbbdffbfcfbb1c2ec38749627464f34f Mon Sep 17 00:00:00 2001 From: Abhishek-kumar-samsung Date: Fri, 3 Feb 2023 19:19:59 +0530 Subject: [PATCH 2/3] made changes to parameterized expand in one cli test file --- tests/cli/commands/test_task_command.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/cli/commands/test_task_command.py b/tests/cli/commands/test_task_command.py index 7e10ad21a1c4d..8e3c02c232bf1 100644 --- a/tests/cli/commands/test_task_command.py +++ b/tests/cli/commands/test_task_command.py @@ -336,12 +336,13 @@ def test_cli_test_with_env_vars(self): assert "foo=bar" in output assert "AIRFLOW_TEST_MODE=True" in output - @parameterized.expand( + @pytest.mark.parametrize( + "option", [ - ("--ignore-all-dependencies",), - ("--ignore-depends-on-past",), - ("--ignore-dependencies",), - ("--force",), + "--ignore-all-dependencies", + "--ignore-depends-on-past", + "--ignore-dependencies", + "--force", ], ) def test_cli_run_invalid_raw_option(self, option: str): From bbd72496d758a8e0f077da8948fc65043c664db1 Mon Sep 17 00:00:00 2001 From: Abhishek-kumar-samsung Date: Fri, 3 Feb 2023 20:56:10 +0530 Subject: [PATCH 3/3] removed unused imports --- tests/cli/commands/test_pool_command.py | 1 - tests/cli/commands/test_task_command.py | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/cli/commands/test_pool_command.py b/tests/cli/commands/test_pool_command.py index 5350d086fb910..ec175912d8503 100644 --- a/tests/cli/commands/test_pool_command.py +++ b/tests/cli/commands/test_pool_command.py @@ -41,7 +41,6 @@ def setup_class(cls): cls.session = Session cls._cleanup() - def tearDown(self): self._cleanup() diff --git a/tests/cli/commands/test_task_command.py b/tests/cli/commands/test_task_command.py index 8e3c02c232bf1..5b9f8ace71919 100644 --- a/tests/cli/commands/test_task_command.py +++ b/tests/cli/commands/test_task_command.py @@ -33,7 +33,6 @@ import pendulum import pytest -from parameterized import parameterized from airflow import DAG from airflow.cli import cli_parser