I have a function which raises a TypeError when some conditions are met.
def myfunc(..args here...):
...
raise TypeError('Message')
I want to test this message using pytest parametrize.
But, because I am using other arguments also I want to have a setup like this:
testdata = [
(..args here..., 'Message'), # Message is the expected output
]
@pytest.mark.parametrize(
"..args here..., expected_output", testdata)
def test_myfunc(
..args here..., expected_output):
obs = myfunc()
assert obs == expected_output
Simple putting the Message
as the expected output in the parametrize testdata, gives me a failing test.