From 5cd6c9a939b060946e1b38e2c2597a5bbac82024 Mon Sep 17 00:00:00 2001 From: Miikka Koistinen Date: Fri, 27 Jul 2018 16:53:51 +0300 Subject: Change assert statements to raises in CheckValue * Instead of using assert statements, raise a custom exception. * Modify the unit tests so that they do not test unused parameters for equality. * Fix pylint and pep8 errors. JIRA: YARDSTICK-966 Change-Id: I41e13a5a22086827792eaf9de8da2e4ed6dd42de Signed-off-by: Miikka Koistinen --- yardstick/benchmark/scenarios/lib/check_value.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'yardstick/benchmark/scenarios') diff --git a/yardstick/benchmark/scenarios/lib/check_value.py b/yardstick/benchmark/scenarios/lib/check_value.py index 759076068..4c9b27df4 100644 --- a/yardstick/benchmark/scenarios/lib/check_value.py +++ b/yardstick/benchmark/scenarios/lib/check_value.py @@ -13,6 +13,7 @@ from __future__ import absolute_import import logging from yardstick.benchmark.scenarios import base +from yardstick.common import exceptions as y_exc LOG = logging.getLogger(__name__) @@ -34,24 +35,18 @@ class CheckValue(base.Scenario): self.context_cfg = context_cfg self.options = self.scenario_cfg['options'] - def run(self, result): + def run(self, _): """execute the test""" op = self.options.get("operator") LOG.debug("options=%s", self.options) value1 = str(self.options.get("value1")) value2 = str(self.options.get("value2")) + if (op == "eq" and value1 != value2) or (op == "ne" and + value1 == value2): + raise y_exc.ValueCheckError( + value1=value1, operator=op, value2=value2) check_result = "PASS" - if op == "eq" and value1 != value2: - LOG.info("value1=%s, value2=%s, error: should equal!!!", value1, - value2) - check_result = "FAIL" - assert value1 == value2, "Error %s!=%s" % (value1, value2) - elif op == "ne" and value1 == value2: - LOG.info("value1=%s, value2=%s, error: should not equal!!!", - value1, value2) - check_result = "FAIL" - assert value1 != value2, "Error %s==%s" % (value1, value2) LOG.info("Check result is %s", check_result) keys = self.scenario_cfg.get('output', '').split() values = [check_result] -- cgit 1.2.3-korg