andriyor
10/6/2015 - 1:38 AM

Parametrized pytest testcase with dictionary of parameters and human readable testcase names

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