本文整理汇总了Python中sympy.core.compatibility.StringIO.close方法的典型用法代码示例。如果您正苦于以下问题:Python StringIO.close方法的具体用法?Python StringIO.close怎么用?Python StringIO.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.core.compatibility.StringIO
的用法示例。
在下文中一共展示了StringIO.close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_debug
# 需要导入模块: from sympy.core.compatibility import StringIO [as 别名]
# 或者: from sympy.core.compatibility.StringIO import close [as 别名]
def test_debug():
from sympy.core.compatibility import StringIO
file = StringIO()
rl = debug(posdec, file)
rl(5)
log = file.getvalue()
file.close()
assert get_function_name(posdec) in log
assert '5' in log
assert '4' in log
示例2: get_string
# 需要导入模块: from sympy.core.compatibility import StringIO [as 别名]
# 或者: from sympy.core.compatibility.StringIO import close [as 别名]
def get_string(dump_fn, routines, prefix="file", header=False, empty=False):
"""Wrapper for dump_fn. dump_fn writes its results to a stream object and
this wrapper returns the contents of that stream as a string. This
auxiliary function is used by many tests below.
The header and the empty lines are not generated to facilitate the
testing of the output.
"""
output = StringIO()
dump_fn(routines, output, prefix, header, empty)
source = output.getvalue()
output.close()
return source