本文整理汇总了Python中testtools.TestCase类的典型用法代码示例。如果您正苦于以下问题:Python TestCase类的具体用法?Python TestCase怎么用?Python TestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestCase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.builder = jenkins_jobs.builder.Builder(
'http://jenkins.example.com',
'doesnot', 'matter',
plugins_list=['plugin1', 'plugin2'],
)
TestCase.setUp(self)
示例2: setUp
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))
示例3: wait_no_exception
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)
示例4: state_wait
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()
示例5: wait_exception
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)
示例6: re_search_wait
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)
示例7: _skipper
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)
示例8: setUp
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))
示例9: tearDown
def tearDown(self):
self._calls.append("tearDown")
TestCase.tearDown(self)
示例10: setUp
def setUp(self):
TestCase.setUp(self)
raise self.skipException("skipping this test")
示例11: setUp
def setUp(self):
TestCase.setUp(self)
self.data = {"a": {"b": {"c": "d"}, "e": "f"}}
示例12: tearDown
def tearDown(self):
ResourcedTestCase.tearDown(self)
TestCase.tearDown(self)
示例13: setUp
def setUp(self):
TestCase.setUp(self)
self.data = {"testcase": {"test-level": 1}}
示例14: setUp
def setUp(self):
TestCase.setUp(self)
result = testresources._get_result()
testresources.setUpResources(self, self.resources, result)
self.addCleanup(
testresources.tearDownResources, self, self.resources, result)
示例15: setUp
def setUp(self):
TestCase.setUp(self)
self.result = [Entity("Q1", [Claim(373, "string", "Universe"),
Claim(31, "wikibase-entityid", "Q223557"),
Claim(31, "wikibase-entityid", "Q1088088")])]