mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
39319c0750
pytest_panic used to do 'from conftest import PanicTestDut'. This stopped working when another conftest.py file was added in tools/test_build_system/conftest.py. In this case we can't rename conftest.py since both are necessary for pytest to install the hooks in the respective test cases. Fix by moving PanicTestDut into a separate module, then importing it from there.
22 lines
658 B
Python
22 lines
658 B
Python
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# pylint: disable=W0621 # redefined-outer-name
|
|
|
|
import pytest
|
|
from _pytest.fixtures import FixtureRequest
|
|
from _pytest.monkeypatch import MonkeyPatch
|
|
from test_panic_util import PanicTestDut
|
|
|
|
|
|
@pytest.fixture(scope='module')
|
|
def monkeypatch_module(request: FixtureRequest) -> MonkeyPatch:
|
|
mp = MonkeyPatch()
|
|
request.addfinalizer(mp.undo)
|
|
return mp
|
|
|
|
|
|
@pytest.fixture(scope='module', autouse=True)
|
|
def replace_dut_class(monkeypatch_module: MonkeyPatch) -> None:
|
|
monkeypatch_module.setattr('pytest_embedded_idf.dut.IdfDut', PanicTestDut)
|