本文整理汇总了Python中nose.util.safe_str函数的典型用法代码示例。如果您正苦于以下问题:Python safe_str函数的具体用法?Python safe_str怎么用?Python safe_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了safe_str函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addCaptureToErr
def addCaptureToErr(self, ev):
lines = []
for (filename, description) in self._filenames_to_description.iteritems():
lines.append(ln('>> begin ''{0}'' <<'.format(description)))
with open(filename, 'r') as fp:
lines += [safe_str(fp.read())]
lines.append(ln('>> end ''{0}'' <<'.format(description)))
lines.append(safe_str(ev))
return '\n'.join(lines)
示例2: addCaptureToErr
def addCaptureToErr(self, ev, records):
result = patcher.original(self).addCaptureToErr(ev, records)
ev = safe_str(ev)
added_lines = result[len(ev):].split('\n')
added_lines[1] = color.green(added_lines[1], bold=True)
added_lines[-1] = color.green(added_lines[-1], bold=True)
return ev + '\n'.join(added_lines)
示例3: formatFailure
def formatFailure(self, test, err):
# Show output
ec, ev, tb = err
captured = self.stream_capturer.get_buffer().decode("utf-8", "replace")
if captured.strip():
ev = safe_str(ev)
out = [ev, ">> begin captured subprocess output <<", captured, ">> end captured subprocess output <<"]
return ec, "\n".join(out), tb
return err
示例4: _dump_logs
def _dump_logs(self, ev, test):
ret = ev
if isinstance(test.test, functional.FunctionalTest):
dump = test.test.dump_logs()
if dump:
ret = '\n'.join([safe_str(ev),
ln('>> begin captured glance logging <<')] +
[dump] +
[ln('>> end captured glance logging <<')])
return ret
示例5: formatFailure
def formatFailure(self, test, err):
# Show output
ec, ev, tb = err
captured = self.stream_capturer.get_buffer().decode('utf-8', 'replace')
if captured.strip():
ev = safe_str(ev)
out = [ev, '>> begin captured subprocess output <<',
captured,
'>> end captured subprocess output <<']
return ec, '\n'.join(out), tb
return err
示例6: addCaptureToErr
def addCaptureToErr(self, ev, records):
return '\n'.join([safe_str(ev), ln('>> begin captured logging <<')] + \
records + \
[ln('>> end captured logging <<')])
示例7: formatLogRecords
def formatLogRecords(self):
format = self.handler.format
return [safe_str(format(r)) for r in self.handler.buffer]
示例8: addCaptureToErr
def addCaptureToErr(self, ev, records):
return "\n".join(
[safe_str(ev), ln(">> begin captured logging <<")] + records + [ln(">> end captured logging <<")]
)