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.
Reproduction:
conftest.py
import logging
def idmap(obj):
logging.info(obj)
def pytest_generate_tests(metafunc):
if "arg" in metafunc.fixturenames:
metafunc.parametrize(
"arg", [], ids=idmap
)
test_demo.py
$: pytest --collect-only --log-cli-level=DEBUG
...
INFO root:conftest.py:4 NotSetType.token
...
Python: 3.10.15
pytest: 8.3.4
OS: macOS Sonoma 14.6.1