Skip to content
Snippets Groups Projects
Verified Commit 8daa7a9d authored by Karel Koci's avatar Karel Koci :metal:
Browse files

Add marks for configuration requirements

These new marks are intended to be used if specific resource is required
and such test would we run only if that resource was configured for that
target.
parent 324b04f7
No related branches found
No related tags found
1 merge request!2Initial development
......@@ -25,10 +25,6 @@ def pytest_addoption(parser):
def pytest_configure(config):
# Add dynamic markers
config.addinivalue_line(
"markers", "board(boards): mark test to run only on specified board"
)
# Parse target configuration
targets = configparser.ConfigParser()
targets.read(os.path.expanduser("~/.nsfarm_targets.ini"))
......@@ -46,3 +42,6 @@ def pytest_runtest_setup(item):
for boards in item.iter_markers(name="board"):
if board not in boards.args:
pytest.skip("test is not compatible with target: {}".format(board))
for conn in ("serial", "wan", "lan1", "lan2"):
if item.get_closest_marker(conn) is not None and conn not in item.config.target_config:
pytest.skip("test requires connection: {}".format(conn))
......@@ -2,3 +2,8 @@
addopts = --strict-markers
markers =
deploy: quick tests to be run as part of deployment process
board(boards): mark test to run only on specified board
serial: requirement of serial port connection to board
wan: requirement of wan ethernet connection to board
lan1: requirement of lan1 ethernet connection to board
lan2: requirement of lan2 ethernet connection to board
......@@ -3,8 +3,8 @@ import nsfarm.board
import nsfarm.cli
@pytest.fixture(scope="session")
def board(request):
@pytest.fixture(scope="session", name="board", params=[pytest.param(None, marks=pytest.mark.serial)])
def fixture_board(request):
"""Brings board on. Nothing else.
This is top most fixture for board. It returns board handle.
"""
......
import pytest
@pytest.mark.board("omnia")
def test_help(board, board_uboot):
assert board_uboot.run("help")
board.serial_miniterm()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment