Source code for taf.testlib.testenv

# Copyright (c) 2011 - 2017, Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""``testenv.py``

`Environment verifying functionality`

"""


import time
import pytest

from . import loggers


[docs]def get_env_prop(env): """Read properties from all devices. Args: env(Environment): Environment instance """ def get_param(param): """Get single param. """ return "_".join( {str(switch.get_env_prop(param)) for switch in getattr(env, "switch", {}).values()}) env_dict = { 'switchppVersion': get_param("switchppVersion"), 'chipName': get_param("chipName"), 'cpuArchitecture': get_param("cpuArchitecture"), } # Get params from devices return env_dict
[docs]def setup_teardown(function): """Setup/Teardown decorator. """ def wrapper(*args, **kwargs): args[0]._setup() # pylint: disable=protected-access result = function(*args, **kwargs) args[0]._teardown() # pylint: disable=protected-access return result return wrapper