diff --git a/labgrid/config.py b/labgrid/config.py index 9b09dcb5e..def25ec92 100644 --- a/labgrid/config.py +++ b/labgrid/config.py @@ -199,6 +199,12 @@ def get_target_option(self, target, name, default=None): configuration, or if the target can not be found in the configuration. """ + warn( + "get_target_option is deprecated, access the options on the target directly.", + DeprecationWarning, + stacklevel=2, + ) + if target not in self.data['targets']: raise KeyError(f"No target '{target}' found in configuration") @@ -224,6 +230,11 @@ def set_target_option(self, target, name, value): KeyError: if the requested target can not be found in the configuration """ + warn( + "set_target_option is deprecated, use the YAML configuration instead.", + DeprecationWarning, + stacklevel=2, + ) assert isinstance(target, str) assert isinstance(name, str) diff --git a/labgrid/environment.py b/labgrid/environment.py index abff96ce1..293e10605 100644 --- a/labgrid/environment.py +++ b/labgrid/environment.py @@ -55,6 +55,14 @@ def get_features(self): return self.config.get_features() def get_target_features(self): + warn( + "use get_all_features instead. For target features, use target.features instead.", + DeprecationWarning, + stacklevel=2, + ) + return get_all_features() + + def get_all_features(self): flags = set() for value in self.config.get_targets().values(): flags = flags | set(value.get('features', {})) diff --git a/labgrid/factory.py b/labgrid/factory.py index 98d84abd6..7deb5088e 100644 --- a/labgrid/factory.py +++ b/labgrid/factory.py @@ -144,7 +144,9 @@ def make_driver(self, target, driver, name, args): def make_target(self, name, config, *, env=None): from .target import Target - target = Target(name, env=env) + target = Target(name, env=env, + features=frozenset(config.get('features')), + options=frozenset(config.get('options'))) for item in TargetFactory._convert_to_named_list(config.get('resources', {})): resource = item.pop('cls') name = item.pop('name', None) diff --git a/labgrid/pytestplugin/hooks.py b/labgrid/pytestplugin/hooks.py index f69507250..881487388 100644 --- a/labgrid/pytestplugin/hooks.py +++ b/labgrid/pytestplugin/hooks.py @@ -105,7 +105,7 @@ def pytest_collection_modifyitems(config, items): if not env: return - have_feature = env.get_features() | env.get_target_features() + have_feature = env.get_features() | env.get_all_features() for item in items: want_feature = set() diff --git a/labgrid/target.py b/labgrid/target.py index c5184da3c..6cf17d206 100644 --- a/labgrid/target.py +++ b/labgrid/target.py @@ -19,6 +19,8 @@ class Target: name = attr.ib(validator=attr.validators.instance_of(str)) env = attr.ib(default=None) + features = attr.ib(default=set()) + options = attr.ib(default=set()) def __attrs_post_init__(self): self.log = logging.getLogger(f"target({self.name})")