Skip to content

Collected tests' nodeids change depending on parser's option values #11636

@mtsokol

Description

@mtsokol

Hi!

I recently started working with more advanced conftest.py features and I stumbled upon something that looks like an incorrect behavior to me:

❗ Here I share a minimal example to reproduce my issue: https://github.com/mtsokol/pytest-conftest-bug

In a nutshell:

  1. I have a pytest option added to a parser --my-option
  2. I have a custom logic in pytest_collection_modifyitems where I traverse collected tests and decide which one should be skipped.
  3. When I pass an option value that is an arbitrary string, e.g. pytest my_module --my-option foobar the test that is collected has nodeid of 'my_module/test_sth.py::test_foo'
  4. But when the option that I pass is an absolute path pytest my_module --my-option /Users/user/foobar then the test has nodeid of 'test_sth.py::test_foo'

This breaks my test suite as collected tests can't be properly matched/filtered, because a path for one of the options in pytest command changed from relative to absolute.

Would you consider it a bug? Or is it an expected behavior?

I'm using pytest 7.4.3 and macos 12.7.1.

Thank you for any guidance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: configrelated to config handling, argument parsing and config filetype: questiongeneral question, might be closed after 2 weeks of inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions