Source code for labgrid.pytestplugin.fixtures

import pytest

from .. import Environment


# pylint: disable=redefined-outer-name


[docs]def pytest_addoption(parser): group = parser.getgroup('labgrid') group.addoption( '--env-config', action='store', dest='env_config', help='labgrid environment config file.' )
@pytest.fixture('session')
[docs]def env(request): """Return the environment configured in the supplied configuration file. It contains the targets contained in the configuration file. """ env_config = request.config.option.env_config if env_config is None: pytest.skip("missing environemnt config (--env-config)") env = Environment(config_file=request.config.option.env_config, ) yield env env.cleanup()
@pytest.fixture('session')
[docs]def target(env): """Return the default target `main` configured in the supplied configuration file.""" target = env.get_target() target.await_resources() return target