This is an automated email from the ASF dual-hosted git repository.

taragolis pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new f902dbe91f Ban `unittest` marks which presented into the `pytest` 
(#39025)
f902dbe91f is described below

commit f902dbe91f2b8c8675a4599719a0adb4f31346d8
Author: Andrey Anshin <[email protected]>
AuthorDate: Mon Apr 15 20:29:50 2024 +0400

    Ban `unittest` marks which presented into the `pytest` (#39025)
---
 pyproject.toml                              | 9 +++++++--
 tests/cli/commands/test_task_command.py     | 5 ++---
 tests/providers/amazon/aws/hooks/test_s3.py | 2 --
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index cd27952820..08a5a0527c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -461,8 +461,13 @@ banned-module-level-imports = ["numpy", "pandas"]
 "logging.fatal".msg = "Instantiate new `logger = logging.getLogger(__name__)` 
and use it instead of root logger"
 "logging.critical".msg = "Instantiate new `logger = 
logging.getLogger(__name__)` and use it instead of root logger"
 "logging.log".msg = "Instantiate new `logger = logging.getLogger(__name__)` 
and use it instead of root logger"
-# Some specific cases
-"unittest.TestCase".msg = "Use pytest compatible classes"
+# unittest related restrictions
+"unittest.TestCase".msg = "Use pytest compatible classes: 
https://docs.pytest.org/en/stable/getting-started.html#group-multiple-tests-in-a-class";
+"unittest.skip".msg = "Use `pytest.mark.skip` instead: 
https://docs.pytest.org/en/stable/reference/reference.html#marks";
+"unittest.skipIf".msg = "Use `pytest.mark.skipif` instead: 
https://docs.pytest.org/en/stable/reference/reference.html#marks";
+"unittest.skipUnless".msg = "Use `pytest.mark.skipif` instead: 
https://docs.pytest.org/en/stable/reference/reference.html#marks";
+"unittest.expectedFailure".msg = "Use `pytest.mark.xfail` instead: 
https://docs.pytest.org/en/stable/reference/reference.html#marks";
+
 
 [tool.ruff.lint.flake8-type-checking]
 exempt-modules = ["typing", "typing_extensions"]
diff --git a/tests/cli/commands/test_task_command.py 
b/tests/cli/commands/test_task_command.py
index 0c7aad9f49..274ee740c6 100644
--- a/tests/cli/commands/test_task_command.py
+++ b/tests/cli/commands/test_task_command.py
@@ -24,7 +24,6 @@ import os
 import re
 import shutil
 import sys
-import unittest
 from argparse import ArgumentParser
 from contextlib import contextmanager, redirect_stdout
 from io import StringIO
@@ -804,7 +803,7 @@ class TestLogsfromTaskRunCommand:
             # when not k8s executor pod, most output is redirected to logs
             assert len(lines) == 1
 
-    @unittest.skipIf(not hasattr(os, "fork"), "Forking not available")
+    @pytest.mark.skipif(not hasattr(os, "fork"), reason="Forking not 
available")
     def test_logging_with_run_task(self):
         with conf_vars({("core", "dags_folder"): self.dag_path}):
             task_command.task_run(self.parser.parse_args(self.task_args))
@@ -832,7 +831,7 @@ class TestLogsfromTaskRunCommand:
             f"task_id={self.task_id}, execution_date=20170101T000000" in logs
         )
 
-    @unittest.skipIf(not hasattr(os, "fork"), "Forking not available")
+    @pytest.mark.skipif(not hasattr(os, "fork"), reason="Forking not 
available")
     def test_run_task_with_pool(self):
         pool_name = "test_pool_run"
 
diff --git a/tests/providers/amazon/aws/hooks/test_s3.py 
b/tests/providers/amazon/aws/hooks/test_s3.py
index 93b91556fa..eb8a883f64 100644
--- a/tests/providers/amazon/aws/hooks/test_s3.py
+++ b/tests/providers/amazon/aws/hooks/test_s3.py
@@ -21,7 +21,6 @@ import gzip as gz
 import inspect
 import os
 import re
-import unittest
 from datetime import datetime as std_datetime, timezone
 from unittest import mock, mock as async_mock
 from unittest.mock import MagicMock, Mock, patch
@@ -467,7 +466,6 @@ class TestAwsS3Hook:
 
     
@async_mock.patch("airflow.providers.amazon.aws.triggers.s3.S3Hook.async_conn")
     @pytest.mark.asyncio
-    @unittest.expectedFailure
     async def test_s3_key_hook_get_head_object_raise_exception_async(self, 
mock_client):
         """
         Test for 500 error if key not found and assert based on response.

Reply via email to