Closed
Description
As it is right now, to provide non-default test IDs when using pytest.mark.parametrize
, one must use the ids
keyword arg.
However, a thought occurred to me: What if we supply a dict
to parametrize's argvalues, and from that dict, use the keys as the don-default test IDs?
For example, rather than:
@pytest.mark.parametrize(
"command", [
"RCPT",
"RCPT <[email protected]>",
"RCPT TO:",
"RCPT TO: <[email protected]> SIZE=1000",
],
ids=["noarg", "noto", "noaddr", "params"]
)
we can supply it more succinctly like so:
@pytest.mark.parametrize(
"command", {
"noarg": "RCPT",
"noto": "RCPT <[email protected]>",
"noaddr": "RCPT TO:",
"params": "RCPT TO: <[email protected]> SIZE=1000",
}
)
Users who absolutely need ordering can still use the first one, or use OrderedDict
(or standard dict in Python>=3.7, where dict ordering became a language feature.)