import pytest

from tests.pylint_plugins.utils import create_message, extract_node, skip_if_pylint_unavailable

pytestmark = skip_if_pylint_unavailable()


@pytest.fixture(scope="module")
def test_case():
    import pylint.testutils
    from pylint_plugins import AssertRaisesWithoutMsg

    class TestAssertRaisesWithoutMsg(pylint.testutils.CheckerTestCase):
        CHECKER_CLASS = AssertRaisesWithoutMsg

    test_case = TestAssertRaisesWithoutMsg()
    test_case.setup_method()
    return test_case


def test_assert_raises_without_msg(test_case):
    node = extract_node("self.assertRaises(Exception)")
    with test_case.assertAddsMessages(create_message(test_case.CHECKER_CLASS.name, node)):
        test_case.walk(node)

    node = extract_node("self.assertRaises(Exception, msg='test')")
    with test_case.assertNoMessages():
        test_case.walk(node)

    node = extract_node("pandas.assertRaises(Exception)")
    with test_case.assertNoMessages():
        test_case.walk(node)

[((125, 153), 'tests.pylint_plugins.utils.skip_if_pylint_unavailable', 'skip_if_pylint_unavailable', ([], {}), '()\n', (151, 153), False, 'from tests.pylint_plugins.utils import create_message, extract_node, skip_if_pylint_unavailable\n'), ((157, 187), 'pytest.fixture', 'pytest.fixture', ([], {'scope': '"""module"""'}), "(scope='module')\n", (171, 187), False, 'import pytest\n'), ((563, 607), 'tests.pylint_plugins.utils.extract_node', 'extract_node', (['"""self.assertRaises(Exception)"""'], {}), "('self.assertRaises(Exception)')\n", (575, 607), False, 'from tests.pylint_plugins.utils import create_message, extract_node, skip_if_pylint_unavailable\n'), ((740, 796), 'tests.pylint_plugins.utils.extract_node', 'extract_node', (['"""self.assertRaises(Exception, msg=\'test\')"""'], {}), '("self.assertRaises(Exception, msg=\'test\')")\n', (752, 796), False, 'from tests.pylint_plugins.utils import create_message, extract_node, skip_if_pylint_unavailable\n'), ((877, 923), 'tests.pylint_plugins.utils.extract_node', 'extract_node', (['"""pandas.assertRaises(Exception)"""'], {}), "('pandas.assertRaises(Exception)')\n", (889, 923), False, 'from tests.pylint_plugins.utils import create_message, extract_node, skip_if_pylint_unavailable\n'), ((646, 696), 'tests.pylint_plugins.utils.create_message', 'create_message', (['test_case.CHECKER_CLASS.name', 'node'], {}), '(test_case.CHECKER_CLASS.name, node)\n', (660, 696), False, 'from tests.pylint_plugins.utils import create_message, extract_node, skip_if_pylint_unavailable\n')]