当前位置: 首页>>代码示例>>Python>>正文


Python StringIO.getvalue方法代码示例

本文整理汇总了Python中io.StringIO.getvalue方法的典型用法代码示例。如果您正苦于以下问题:Python StringIO.getvalue方法的具体用法?Python StringIO.getvalue怎么用?Python StringIO.getvalue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.StringIO的用法示例。


在下文中一共展示了StringIO.getvalue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: runTest

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import getvalue [as 别名]
def runTest(self):
        test = self._dt_test
        old = sys.stdout
        new = StringIO()
        optionflags = self._dt_optionflags

        if not (optionflags & REPORTING_FLAGS):
            # The option flags don't include any reporting flags,
            # so add the default reporting flags
            optionflags |= _unittest_reportflags

        runner = DocTestRunner(optionflags=optionflags,
                               checker=self._dt_checker, verbose=False)

        try:
            runner.DIVIDER = "-"*70
            failures, tries = runner.run(
                test, out=new.write, clear_globs=False)
        finally:
            sys.stdout = old

        if failures:
            raise self.failureException(self.format_failure(new.getvalue())) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:25,代码来源:doctest.py

示例2: read

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import getvalue [as 别名]
def read(self, *args):
        return self.getvalue() 
开发者ID:BnetButter,项目名称:hwk-mirror,代码行数:4,代码来源:stream.py

示例3: __iter__

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import getvalue [as 别名]
def __iter__(self):
        self.count = 0
        self.iterable = self.getvalue().split('\n')
        self.max = len(self.iterable)
        return self 
开发者ID:BnetButter,项目名称:hwk-mirror,代码行数:7,代码来源:stream.py

示例4: __aiter__

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import getvalue [as 别名]
def __aiter__(self):
        self.count = 0
        self.iterable = self.getvalue().split('\n')
        self.max = len(self.iterable)
        return self 
开发者ID:BnetButter,项目名称:hwk-mirror,代码行数:7,代码来源:stream.py

示例5: _exception_traceback

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import getvalue [as 别名]
def _exception_traceback(exc_info):
    """
    Return a string containing a traceback message for the given
    exc_info tuple (as returned by sys.exc_info()).
    """
    # Get a traceback message.
    excout = StringIO()
    exc_type, exc_val, exc_tb = exc_info
    traceback.print_exception(exc_type, exc_val, exc_tb, file=excout)
    return excout.getvalue()

# Override some StringIO methods. 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:14,代码来源:doctest.py

示例6: getvalue

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import getvalue [as 别名]
def getvalue(self):
        result = StringIO.getvalue(self)
        # If anything at all was written, make sure there's a trailing
        # newline.  There's no way for the expected output to indicate
        # that a trailing newline is missing.
        if result and not result.endswith("\n"):
            result += "\n"
        return result 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:10,代码来源:doctest.py


注:本文中的io.StringIO.getvalue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。