def setUpClass(cls): TestCase.setUpClass() manager.eon.db = mock.MagicMock() manager.rpcapi = mock.MagicMock() cls.manager = manager.ResourceManager() cls.context = "context" cls.resource_type = "vmware" cls.db_resource_mgr = mock.MagicMock() cls.db_resource = mock.MagicMock() cls.db_resource_mgrs = [ cls.db_resource_mgr, ] cls.db_resources = [ cls.db_resource, ] cls.db_resource_mgr_pty = { "key": "vcenter_uuid", "value": "vcenter-123", "id": "123", } cls.db_resource_ptys = [ cls.db_resource_mgr_pty, ] cls.data_without_meta = { "name": "vcenter1", "port": "443", "ip_address": "10.1.192.98", "username": "******", "password": "******", "type": "vmware", } cls.data = cls._get_data()
def setUp(self): self.builder = jenkins_jobs.builder.Builder( 'http://jenkins.example.com', 'doesnot', 'matter', plugins_list=['plugin1', 'plugin2'], ) TestCase.setUp(self)
def setUp(self): TestCase.setUp(self) out = StringIO() out.writelines(["Q1,373,string,Universe\n", "Q1,31,wikibase-entityid,Q223557\n", "Q1,31,wikibase-entityid,Q1088088\n"]) out.seek(0) self.result = list(CsvReader.read_csv(out))
def on_test_case_retry_exception(attempt: RetryAttempt, test_case: testtools.TestCase, *_args, **_kwargs): # pylint: disable=protected-access _exception.check_valid_type(test_case, testtools.TestCase) test_case._report_traceback(sys.exc_info(), f"traceback[attempt={attempt.number}]") LOG.exception("Re-run test after failed attempt. " f"(attempt={attempt.number}, test='{test_case.id()}')")
def setUp(self): TestCase.setUp(self) out = StringIO() out.writelines([ "Q1,373,string,Universe\n", "Q1,31,wikibase-entityid,Q223557\n", "Q1,31,wikibase-entityid,Q1088088\n" ]) out.seek(0) self.result = list(CsvReader.read_csv(out))
def setUp(self): TestCase.setUp(self) self.result = [ Entity("Q1", [ Claim(373, "string", "Universe"), Claim(31, "wikibase-entityid", "Q223557"), Claim(31, "wikibase-entityid", "Q1088088") ]) ]
def setUp(self): self.yaml_fn = os.path.join(os.path.dirname(__file__), 'job.yaml') self.xml_fn = os.path.join(os.path.dirname(__file__), 'job.xml') self.builder = jenkins_jobs.builder.Builder( 'http://jenkins.example.com', 'doesnot', 'matter', plugins_list=[], ) TestCase.setUp(self)
def setUpClass(cls): TestCase.setUpClass() cls.ip = "10.1.8.8" cls.port = "5985" cls.username = "******" cls.password = "******" cls.ps_script = "ls" cls.cmd_script = "dir" cls.cmd_output_tuple = ("std_out", "std_err", 0) cls.connection_err = \ "Connection fail OR WinRM not properly configured..."
def wait_no_exception(lfunction, exc_class=None, exc_matcher=None): """Stops waiting on success.""" start_time = time.time() if exc_matcher is not None: exc_class = boto.exception.BotoServerError if exc_class is None: exc_class = BaseException while True: result = None try: result = lfunction() LOG.info('No Exception in %d second', time.time() - start_time) return result except exc_class as exc: if exc_matcher is not None: res = exc_matcher.match(exc) if res is not None: LOG.info(res) raise exc # Let the other exceptions propagate dtime = time.time() - start_time if dtime > default_timeout: raise TestCase.failureException("Wait timeout exceeded! (%ds)" % dtime) time.sleep(default_check_interval)
def wait_no_exception(lfunction, exc_class=None, exc_matcher=None): """Stops waiting on success.""" start_time = time.time() if exc_matcher is not None: exc_class = boto.exception.BotoServerError if exc_class is None: exc_class = BaseException while True: result = None try: result = lfunction() LOG.info('No Exception in %d second', time.time() - start_time) return result except exc_class as exc: if exc_matcher is not None: res = exc_matcher.match(exc) if res is not None: LOG.info(res) raise exc # Let the other exceptions propagate dtime = time.time() - start_time if dtime > CONF.boto.build_timeout: raise TestCase.failureException("Wait timeout exceeded! (%ds)" % dtime) time.sleep(CONF.boto.build_interval)
def state_wait(lfunction, final_set=set(), valid_set=None): #TODO(afazekas): evaluate using ABC here if not isinstance(final_set, set): final_set = set((final_set, )) if not isinstance(valid_set, set) and valid_set is not None: valid_set = set((valid_set, )) start_time = time.time() old_status = status = lfunction() while True: if status != old_status: LOG.info('State transition "%s" ==> "%s" %d second', old_status, status, time.time() - start_time) if status in final_set: return status if valid_set is not None and status not in valid_set: return status dtime = time.time() - start_time if dtime > default_timeout: raise TestCase.failureException("State change timeout exceeded!" '(%ds) While waiting' 'for %s at "%s"' % (dtime, final_set, status)) time.sleep(default_check_interval) old_status = status status = lfunction()
def state_wait(lfunction, final_set=set(), valid_set=None): # TODO(afazekas): evaluate using ABC here if not isinstance(final_set, set): final_set = set((final_set,)) if not isinstance(valid_set, set) and valid_set is not None: valid_set = set((valid_set,)) start_time = time.time() old_status = status = lfunction() while True: if status != old_status: LOG.info('State transition "%s" ==> "%s" %d second', old_status, status, time.time() - start_time) if status in final_set: return status if valid_set is not None and status not in valid_set: return status dtime = time.time() - start_time if dtime > CONF.boto.build_timeout: raise TestCase.failureException("State change timeout exceeded!" '(%ds) While waiting' 'for %s at "%s"' % (dtime, final_set, status)) time.sleep(CONF.boto.build_interval) old_status = status status = lfunction()
def wait_exception(lfunction): """Returns with the exception or raises one.""" start_time = time.time() while True: try: lfunction() except BaseException as exc: LOG.info('Exception in %d second', time.time() - start_time) return exc dtime = time.time() - start_time if dtime > default_timeout: raise TestCase.failureException("Wait timeout exceeded! (%ds)" % dtime) time.sleep(default_check_interval)
def wait_exception(lfunction): """Returns with the exception or raises one.""" start_time = time.time() while True: try: lfunction() except BaseException as exc: LOG.info('Exception in %d second', time.time() - start_time) return exc dtime = time.time() - start_time if dtime > CONF.boto.build_timeout: raise TestCase.failureException("Wait timeout exceeded! (%ds)" % dtime) time.sleep(CONF.boto.build_interval)
def re_search_wait(lfunction, regexp): """Stops waiting on success.""" start_time = time.time() while True: text = lfunction() result = re.search(regexp, text) if result is not None: LOG.info('Pattern "%s" found in %d second in "%s"', regexp, time.time() - start_time, text) return result dtime = time.time() - start_time if dtime > default_timeout: raise TestCase.failureException('Pattern find timeout exceeded!' '(%ds) While waiting for' '"%s" pattern in "%s"' % (dtime, regexp, text)) time.sleep(default_check_interval)
def re_search_wait(lfunction, regexp): """Stops waiting on success.""" start_time = time.time() while True: text = lfunction() result = re.search(regexp, text) if result is not None: LOG.info('Pattern "%s" found in %d second in "%s"', regexp, time.time() - start_time, text) return result dtime = time.time() - start_time if dtime > CONF.boto.build_timeout: raise TestCase.failureException('Pattern find timeout exceeded!' '(%ds) While waiting for' '"%s" pattern in "%s"' % (dtime, regexp, text)) time.sleep(CONF.boto.build_interval)
def setUp(self): TestCase.setUp(self) self._result_calls = [] self.test = TestAddCleanup.LoggingTest('runTest') self.logging_result = LoggingResult(self._result_calls)
def setUp(self): TestCase.setUp(self) manager.eon.db = mock.MagicMock() self.mocked_obj = mock.Mock()
def tearDown(self): self._calls.append('tearDown') TestCase.tearDown(self)
def setUp(self): TestCase.setUp(self) raise self.skipException("skipping this test")
def tearDownClass(cls): TestCase.tearDownClass()
def setUp(self): TestCase.setUp(self) with gzip.open(resource_filename(__name__, "Wikidata-Q1.xml.gz"), "r") as f: self.result = list(XmlReader.read_xml(f))
def setUp(self): TestCase.setUp(self) self.result = [Entity("Q1", [Claim(373, "string", "Universe"), Claim(31, "wikibase-entityid", "Q223557"), Claim(31, "wikibase-entityid", "Q1088088")])]
def setUp(self): TestCase.setUp(self) self.data = {"testcase": {"test-level": 1}}
def setUp(self): TestCase.setUp(self) self.dbname = self._testMethodName self.db = CouchDatabase(self.dbname, create=True) self.record_type = "test_record_type"
def setUp(self): TestCase.setUp(self) self._calls = ['setUp']
def test_nonIdenticalInUnequal(self): # TestCase's are not equal if they are not identical. self.assertNotEqual(TestCase(methodName='run'), TestCase(methodName='skip'))
def setUp(self): TestCase.setUp(self) ResourcedTestCase.setUp(self)
def setUp(self): TestCase.setUp(self) manager.manager = mock.MagicMock() manager.greenpool = mock.MagicMock() self.context = "context" self.manager = manager.ConductorManager("host", "topic")
def setUp(self): TestCase.setUp(self) self.skip("skipping this test")
def tearDown(self): """tear down each test""" TestCase.tearDown(self) #delete the database del self.db._server[self.dbname]
def _skipper(*args, **kw): """Wrapped skipper function.""" testobj = args[0] if not getattr(testobj, self.attr, False): raise TestCase.skipException(self.message) func(*args, **kw)
def setUp(self): TestCase.setUp(self) self.data = {"a": {"b": {"c": "d"}, "e": "f"}}
def setUp(self): TestCase.setUp(self) message_notifier.notifier = TestNotifier() global NOTIFICATIONS self.notifications = NOTIFICATIONS = []
def tearDown(self): ResourcedTestCase.tearDown(self) TestCase.tearDown(self)
def setUp(self): TestCase.setUp(self) result = testresources._get_result() testresources.setUpResources(self, self.resources, result) self.addCleanup( testresources.tearDownResources, self, self.resources, result)
def tearDown(self): TestCase.tearDown(self)
def tearDown(self): self._calls.append("tearDown") TestCase.tearDown(self)
def __init__(self, *args, **kwargs): TestCase.__init__(self, *args, **kwargs) self._workdir = None self._environ_restore = None
def setUp(self): TestCase.setUp(self)
def setUp(self): TestCase.setUp(self) self.file = StringIO()
def setUp(self): TestCase.setUp(self) self._calls = ["setUp"]