def report(self, fileobj=None, indent=0): """ Generates a text report on the differences (if any) between two objects, and either returns it as a string or writes it to a file-like object. Parameters ---------- fileobj : file-like object or None (optional) If `None`, this method returns the report as a string. Otherwise it returns `None` and writes the report to the given file-like object (which must have a `.write()` method at a minimum). indent : int The number of 4 space tabs to indent the report. Returns ------- report : str or None """ return_string = False if fileobj is None: fileobj = StringIO() return_string = True self._fileobj = fileobj self._indent = indent # This is used internally by _writeln self._report() if return_string: return fileobj.getvalue()