我们从Python开源项目中,提取了以下20个代码示例,用于说明如何使用StringIO.StringIO.truncate()。
def truncate(self, size=None): StringIO.truncate(self, size) if hasattr(self, "softspace"): del self.softspace if not self.buf: # Reset it to an empty string, to make sure it's not unicode. self.buf = '' # Worst-case linear-time ellipsis matching.
def truncate(self, size=None): StringIO.truncate(self, size) if hasattr(self, "softspace"): del self.softspace # Worst-case linear-time ellipsis matching.
def truncate(self, size=None): StringIO.truncate(self, size) if hasattr(self, "softspace"): del self.softspace ########################################################################### # Update Runner ###########################################################################
def _check_output(self, example): want = example.want optionflags = self._get_optionflags(example) got = sys.stdout.getvalue() sys.stdout.truncate(0) if not self.checker.check_output(want, got, optionflags): self.runner.report_failure(self.save_stdout.write, self.test, example, got) return False else: return True