Skip to content

Item._obj is not guaranteed to exist #542

@dmtucker

Description

@dmtucker

return getattr(item._obj, '__allure_display_name__', None)

This code has come up in a pytest-mypy issue because ._obj (which seems to be available publicly as .obj, btw) is not defined on MypyItems (custom pytest.Items used for running mypy on collected modules). Moreover, I don't know of a way to reasonably define it since MypyItems are not associated with any particular test function. That suggests that perhaps allure-pytest should be made to ignore such Items or, in this case, at least gracefully degrade into returning None when allure_title is called on them:

try:
    return item.obj.__allure_display_name__
except AttributeError:
    return None

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