def test_parse_keystring(keystr, expected): if expected is utils.KeyParseError: with pytest.raises(utils.KeyParseError): utils.parse_keystring(keystr) else: assert utils.parse_keystring(keystr) == expected