Skip to content

Commit

Permalink
Remove unnecessary parametrized
Browse files Browse the repository at this point in the history
  • Loading branch information
jiwaszki committed Aug 25, 2024
1 parent 68cfd13 commit f98b5d4
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions tests/test_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,41 +51,18 @@ def test_warning_double_register_fail():

def test_warning_register():
assert m.CustomWarning is not None
assert issubclass(m.CustomWarning, DeprecationWarning)

with pytest.warns(m.CustomWarning) as excinfo:
warnings.warn("This is warning from Python!", m.CustomWarning, stacklevel=1)

assert issubclass(excinfo[0].category, DeprecationWarning)
assert issubclass(excinfo[0].category, m.CustomWarning)
assert str(excinfo[0].message) == "This is warning from Python!"


@pytest.mark.parametrize(
(
"expected_category",
"expected_base",
"expected_message",
"expected_value",
"module_function",
),
[
(
m.CustomWarning,
DeprecationWarning,
"This is CustomWarning",
37,
m.warn_with_custom_type,
),
],
)
def test_warning_custom(
expected_category, expected_base, expected_message, expected_value, module_function
):
with pytest.warns(expected_category) as excinfo:
value = module_function()
def test_warning_custom():
with pytest.warns(m.CustomWarning) as excinfo:
value = m.warn_with_custom_type()

assert issubclass(excinfo[0].category, expected_base)
assert issubclass(excinfo[0].category, expected_category)
assert str(excinfo[0].message) == expected_message
assert value == expected_value
assert issubclass(excinfo[0].category, DeprecationWarning)
assert str(excinfo[0].message) == "This is CustomWarning"
assert value == 37

0 comments on commit f98b5d4

Please sign in to comment.