python: fix empty parametrize() leading to "NotSetType.token" id

In ff8b7884e8 NOTSET was changed to a
singleton enum, which ended up unexpectedly triggering a code path in ID
generation which checks for `isinstance(Enum)`.

Add an explicit case for it, which is not too bad anyway.
This commit is contained in:
Ran Benita
2020-08-25 21:51:08 +03:00
parent 00996adeb8
commit a267a622eb
3 changed files with 14 additions and 0 deletions

View File

@@ -1293,6 +1293,9 @@ def _idval(
return str(val)
elif isinstance(val, REGEX_TYPE):
return ascii_escaped(val.pattern)
elif val is NOTSET:
# Fallback to default. Note that NOTSET is an enum.Enum.
pass
elif isinstance(val, enum.Enum):
return str(val)
elif isinstance(getattr(val, "__name__", None), str):