Skip to content

Instantly share code, notes, and snippets.

@poros
Created October 6, 2015 01:38
Show Gist options
  • Save poros/4ce8cedd0c2311b3d7fd to your computer and use it in GitHub Desktop.
Save poros/4ce8cedd0c2311b3d7fd to your computer and use it in GitHub Desktop.
Parametrized pytest testcase with dictionary of parameters and human readable testcase names
test_params = {
'empty_line': ('', {}),
'get_ok': ('GET 200', {'request': 'GET', 'status': '200'}),
'get_not_found': ('GET 404', {'request': 'GET', 'status': '404'}),
}
@pytest.mark.parametrize('line,expected', test_params.values(), ids=test_params.keys())
def test_decode(self, line, expected):
assert Decoder().decode(line) == expected
@cgebbe
Copy link

cgebbe commented Feb 12, 2021

Thank you! Very helpful and concise :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment