zephyr/samples/subsys/testsuite/pytest/pytest/conftest.py
YouhuaX Zhu 2dc693bbed tests: pytest: add an example for pytest
In this example, python test case get the running directory by handling
the "--cmdopt" option passed by pytest.

Signed-off-by: YouhuaX Zhu <youhuax.zhu@intel.com>
2021-05-04 19:08:18 -04:00

18 lines
485 B
Python

# Copyright (c) 2020 Intel Corporation.
#
# SPDX-License-Identifier: Apache-2.0
import pytest
# add option "--comdopt" to pytest, or it will report "unknown option"
# this option is passed from twister.
def pytest_addoption(parser):
parser.addoption(
'--cmdopt'
)
# define fixture to return value of option "--cmdopt", this fixture
# will be requested by other fixture of tests.
@pytest.fixture()
def cmdopt(request):
return request.config.getoption('--cmdopt')