Skip to content

Xfail marker for non-standard Item missing obj #2231

Closed
@vidartf

Description

@vidartf

Hi!

We're currently writing a plugin for py.test that collects custom tests (i.e. our own class that inherits from pytest.Item). I want to add an xfail marker to these, so I try to do this dynamically via item.add_marker(). If I do this, and run the tests, it will fail on this line:

d.update(self.item.obj.__globals__)

Here, the skipping plugin assumes that the item has an obj attribute, which again has a __globals__ attribute. I can side-step this issue by simply adding a dummy variable here, with an empty __globals__ dict, but I want to ensure that:

  • I am not doing something stupid by adding the dummy
  • I am not doing something wrong elsewhere since I am missing the obj attribute
  • I report this so that I minimize the risk of our plugin failing for similar reasons in the future

Am I doing it right? 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions