Repository: mlflow/mlflow

Issue:
Enable `PT027`
### Summary

- Enable [PT027](https://beta.ruff.rs/docs/rules/pytest-unittest-raises-assertion/).
- Remove `unittest-assert-raises`.

```diff
diff --git a/pylintrc b/pylintrc
index 9148d110e..342dfc943 100644
--- a/pylintrc
+++ b/pylintrc
@@ -79,7 +79,6 @@ enable=signature-differs,
        # Built-in rules
        # --------------
        # Custom rules
-       unittest-assert-raises,
        lazy-builtin-import,
        useless-assignment,
 
diff --git a/pyproject.toml b/pyproject.toml
index 6c64df56e..120e8420c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -32,6 +32,7 @@ select = [
   "PT022",
   "PT023",
   "PT026",
+  "PT027",
   "RUF010",
   "UP004",
   "UP008",
```

### Notes

- Make sure to open a PR from a **non-master** branch.
- Sign off the commit using the `-s` flag when making a commit:

  ```sh
  git commit -s -m "..."
           # ^^ make sure to use this
  ```

- Include `#{issue_number}` (e.g. `#123`) in the PR description when opening a PR.



Discussion:

Resolving patch:
diff --git a/pylint_plugins/__init__.py b/pylint_plugins/__init__.py
--- a/pylint_plugins/__init__.py
+++ b/pylint_plugins/__init__.py
@@ -1,9 +1,7 @@
-from pylint_plugins.unittest_assert_raises import UnittestAssertRaises
 from pylint_plugins.import_checker import ImportChecker
 from pylint_plugins.assign_checker import AssignChecker
 
 
 def register(linter):
-    linter.register_checker(UnittestAssertRaises(linter))
     linter.register_checker(ImportChecker(linter))
     linter.register_checker(AssignChecker(linter))
diff --git a/pylint_plugins/errors.py b/pylint_plugins/errors.py
--- a/pylint_plugins/errors.py
+++ b/pylint_plugins/errors.py
@@ -16,14 +16,6 @@ def to_msgs(*messages: Message) -> Dict[str, Tuple[str, str, str]]:
     return reduce(lambda x, y: {**x, **y.to_dict()}, messages, {})
 
 
-UNITTEST_PYTEST_RAISES = Message(
-    id="W0003",
-    name="unittest-assert-raises",
-    message="Use `pytest.raises` instead of `unittest.TestCase.assertRaises`.",
-    reason="To enforce 'pytest-raises-multiple-statements' Message.",
-)
-
-
 LAZY_BUILTIN_IMPORT = Message(
     id="W0007",
     name="lazy-builtin-import",
diff --git a/pylint_plugins/unittest_assert_raises.py b/pylint_plugins/unittest_assert_raises.py
deleted file mode 100644
--- a/pylint_plugins/unittest_assert_raises.py
+++ /dev/null
@@ -1,23 +0,0 @@
-import astroid
-from pylint.interfaces import IAstroidChecker
-from pylint.checkers import BaseChecker
-
-from pylint_plugins.errors import UNITTEST_PYTEST_RAISES, to_msgs
-
-
-def _is_unittest_assert_raises(node: astroid.Call):
-    return isinstance(node.func, astroid.Attribute) and (
-        node.func.as_string() in ("self.assertRaises", "self.assertRaisesRegex")
-    )
-
-
-class UnittestAssertRaises(BaseChecker):
-    __implements__ = IAstroidChecker
-
-    name = "unittest-assert-raises"
-    msgs = to_msgs(UNITTEST_PYTEST_RAISES)
-    priority = -1
-
-    def visit_call(self, node: astroid.Call):
-        if _is_unittest_assert_raises(node):
-            self.add_message(UNITTEST_PYTEST_RAISES.name, node=node)


Test patch:
diff --git a/pylint_plugins/tests/test_unittest_assert_raises.py b/pylint_plugins/tests/test_unittest_assert_raises.py
deleted file mode 100644
--- a/pylint_plugins/tests/test_unittest_assert_raises.py
+++ /dev/null
@@ -1,33 +0,0 @@
-import pytest
-import astroid
-from pylint.testutils import MessageTest
-from pylint.testutils import CheckerTestCase
-from pylint_plugins import UnittestAssertRaises
-
-
-@pytest.fixture(scope="module")
-def test_case():
-    class TestUnittestAssertRaises(CheckerTestCase):
-        CHECKER_CLASS = UnittestAssertRaises
-
-    test_case = TestUnittestAssertRaises()
-    test_case.setup_method()
-    return test_case
-
-
-def test_unittest_assert_raises(test_case):
-    node = astroid.extract_node("self.assertRaises(Exception)")
-    with test_case.assertAddsMessages(
-        MessageTest(test_case.CHECKER_CLASS.name, node=node, line=1, col_offset=0)
-    ):
-        test_case.walk(node)
-
-    node = astroid.extract_node("self.assertRaisesRegex(Exception, 'error message')")
-    with test_case.assertAddsMessages(
-        MessageTest(test_case.CHECKER_CLASS.name, node=node, line=1, col_offset=0)
-    ):
-        test_case.walk(node)
-
-    node = astroid.extract_node("pytest.raises(Exception, 'error message')")
-    with test_case.assertNoMessages():
-        test_case.walk(node)
diff --git a/pylint_plugins/tests/utils.py b/pylint_plugins/tests/utils.py
deleted file mode 100644
--- a/pylint_plugins/tests/utils.py
+++ /dev/null
@@ -1,11 +0,0 @@
-import subprocess
-import re
-
-from pylint.constants import MSG_TYPES
-
-
-def get_pylint_msg_ids():
-    res = subprocess.run(["pylint", "--list-msgs"], stdout=subprocess.PIPE, check=True)
-    stdout = res.stdout.decode("utf-8")
-    letters = "".join(MSG_TYPES.keys())
-    return set(re.findall(rf"\(([{letters}][0-9]{{4}})\)", stdout))