Skip to content

plugin hook pytest_runtest_teardown runs on skipped test #3385

Closed
@lodagro

Description

@lodagro

conftest.py

import pytest


class MyPlugin:

    def pytest_runtest_setup(self, item):
        raise Exception

    def pytest_runtest_teardown(self, item):
        raise Exception


def pytest_configure(config):
    config.pluginmanager.register(MyPlugin(), "myplugin")

test_teardown.py

import pytest

@pytest.mark.skip
def test_somestuff():
    pass

run output (with relevant version info)

=============================== test session starts ================================
platform linux -- Python 3.6.3, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
metadata: {'Python': '3.6.3', 'Platform': 'Linux-2.6.32-358.23.2.el6.x86_64-x86_64-with-redhat-6.4-Santiago', 'Packages': {'pytest': '3.5.0', 'py': '1.5.3', 'pluggy': '0.4.0'}, 'Plugins': {'metadata': '1.5.0', 'hypothesis': '3.11.6'}}
rootdir: /projects/hardware/BCM65550/users/wovermei/sandbox/plugin_teardown, inifile:
plugins: metadata-1.5.0, hypothesis-3.11.6
collected 1 item                                                                   

test_teardown.py sE                                                          [100%]

====================================== ERRORS ======================================
_______________________ ERROR at teardown of test_somestuff ________________________

self = <conftest.MyPlugin object at 0x7f0dbfaf1fd0>
item = <Function 'test_somestuff'>

    def pytest_runtest_teardown(self, item):
>       raise Exception
E       Exception

conftest.py:10: Exception
======================== 1 skipped, 1 error in 0.05 seconds ========================

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