From: Rodolfo Alonso Hernandez Date: Tue, 26 Jun 2018 09:53:14 +0000 (+0000) Subject: Merge "Refactor "utils.parse_ini_file" testing" X-Git-Tag: opnfv-7.0.0~238 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=43b447c3fc3be4947545d1e16098424bef7be171;p=yardstick.git Merge "Refactor "utils.parse_ini_file" testing" --- 43b447c3fc3be4947545d1e16098424bef7be171 diff --cc yardstick/tests/unit/common/test_utils.py index 31b10e6da,826c55e7a..6e7a0bfc4 --- a/yardstick/tests/unit/common/test_utils.py +++ b/yardstick/tests/unit/common/test_utils.py @@@ -19,8 -19,8 +19,7 @@@ from six.moves import configparse import time import unittest - import yardstick from yardstick import ssh -import yardstick.error from yardstick.common import constants from yardstick.common import utils from yardstick.common import exceptions @@@ -991,8 -1068,16 +1067,8 @@@ class TestUtils(ut_base.BaseUnitTestCas with self.assertRaises(RuntimeError): utils.validate_non_string_sequence(1, raise_exc=RuntimeError) - def test_error_class(self): - with self.assertRaises(RuntimeError): - yardstick.error.ErrorClass() - - error_instance = yardstick.error.ErrorClass(test='') - with self.assertRaises(AttributeError): - error_instance.get_name() - - class TestUtilsIpAddrMethods(unittest.TestCase): + class TestUtilsIpAddrMethods(ut_base.BaseUnitTestCase): GOOD_IP_V4_ADDRESS_STR_LIST = [ u'0.0.0.0', @@@ -1174,19 -1259,8 +1250,19 @@@ class TimerTestCase(ut_base.BaseUnitTes with utils.Timer(timeout=1): time.sleep(2) + def test__enter_with_timeout_no_exception(self): + with utils.Timer(timeout=1, raise_exception=False): + time.sleep(2) + + def test__iter(self): + iterations = [] + for i in utils.Timer(timeout=2): + iterations.append(i) + time.sleep(1.1) + self.assertEqual(2, len(iterations)) + - class WaitUntilTrueTestCase(unittest.TestCase): + class WaitUntilTrueTestCase(ut_base.BaseUnitTestCase): def test_no_timeout(self): self.assertIsNone(utils.wait_until_true(lambda: True,