Skip to content

report.nodeid is not proper in pytest_runtest_logreport() hook for setup/teardown #4629

@raoyitao

Description

@raoyitao

I ran pytest 3.6.0 with python 3.4 on redhat 6.

I have a module pytest_tasks.py and a test class named 'TestClassOne', in which there's a testcase named 'test_success'. And I wrote a plugin with pytest_runtest_logreport() hook.

If I define a setup_method(self, method) in TestClassOne, then in pytest_runtest_logreport(self, report) I can get:
report.when == 'setup'
report.nodeid == 'pytest_tasks.py::TestClassOne::()::test_success'

I think this information is correct.

If I define a classmethod setup_class(cls), or a setup_module(module) in module scope, then I would expect to have report.nodeid equal to 'pytest_tasks.py::TestClassOne' and 'pytest_tasks.py' respectively, because the setup() works in suite scope or module scope, but the value is always 'pytest_tasks.py::TestClassOne::()::test_success'. So when I get a setup report I don't know which level it is, how can I get the correct information ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: collectionrelated to the collection phasetype: 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