You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Parametrizing a test with an empty list calls ids callback with the private constant NOTSETÂ #13031
I parametrize tests based on a user-provided list. Sometimes this list is empty, which disables some tests as a result. However, I would expect the ids callback that I provide to not be called at all in that case, but it is actually called with the private NOTSET sentinel. As this is not exported, I can't easily check for it in my ids function and return a useless value to match it.
Yes, which is reasonable - but I can't detect this in my ID mapping function because it's a hidden type. Perhaps the sentinel can just be exported? Or don't call the ID map for the "no parametrization" case.
I don't quite understand - I don't get access to the ParameterSet, and thus can't see its marks. I simply get NOTSET passed to the ids callback. Because NOTSET is internal to Pytest, I cannot compare the arg against it nor type annotate my ids function to accept it.
Activity
RonnyPfannschmidt commentedon Dec 6, 2024
For empty id lists we generate a single test with a warning
mon commentedon Dec 6, 2024
Yes, which is reasonable - but I can't detect this in my ID mapping function because it's a hidden type. Perhaps the sentinel can just be exported? Or don't call the ID map for the "no parametrization" case.
I can make a PR in either case!
RonnyPfannschmidt commentedon Dec 6, 2024
https://github.com/pytest-dev/pytest/blob/main/src%2F_pytest%2Fmark%2Fstructures.py#L182-L186
mon commentedon Dec 6, 2024
I don't quite understand - I don't get access to the ParameterSet, and thus can't see its marks. I simply get
NOTSETpassed to theidscallback. BecauseNOTSETis internal to Pytest, I cannot compare the arg against it nor type annotate my ids function to accept it.RonnyPfannschmidt commentedon Dec 6, 2024
indeed - we should use a string that indicates it
RonnyPfannschmidt commentedon Dec 6, 2024
i have a wip pr that sets the string NOTSET as direct id to avoid this - 'll polish it a litlle and push
fix pytest-dev#13031: use the concrete id NOTSET for the empty parameâĶ
fix pytest-dev#13031: use the concrete id NOTSET for the empty parameâĶ
fix pytest-dev#13031: use the concrete id NOTSET for the empty parameâĶ
fix pytest-dev#13031: use the concrete id NOTSET for the empty parameâĶ
fix pytest-dev#13031: use the concrete id NOTSET for the empty parameâĶ
mon commentedon Dec 22, 2024
Fantastic, thank you so much!
chore(deps): update dependency pytest to v9 (#305)