Skip to content

"Empty id" mechanism in callspec #8155

@smarie

Description

@smarie

Hi dear pytest maintainers,

I noticed that starting in pytest 5.4.0, CallSpec2.id does not automatically filter out ids that are empty strings from the ids list. So if in the ids list there is ['a', '', 'b'] in old versions that would lead to id 'a-b' and now it leads to 'a--b'. I understand the rationale: pytest should not hide anything from users, so if there is an empty string id somewhere, it should appear.

Unfortunately I was relying on this undocumented mechanism in pytest-cases, because there is a specific situation with fixture unions induced by the new @parametrize, in which I wish to remove a useless piece of id from a callspec. I found an ugly workaround: to use a very long and unique string constant as a marker for "id to remove" and then have a specific cleaning hook in the plugin removing such constants from callspec ids lists.

I was wondering if there could be a better way for the future, baked in the pytest API. For example we could introduce an explicit pytest.NO_ID constant that would be filtered out in CallSpec2.id.

What do you think ? I can propose a PR if needed

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions