diff --git a/borg/helpers.py b/borg/helpers.py index 5a93bd182..b793ca492 100644 --- a/borg/helpers.py +++ b/borg/helpers.py @@ -168,6 +168,12 @@ def update(self, size, csize, unique): def __str__(self): return self.summary.format(stats=self, label='This archive:') + def __repr__(self): + fmt = "<{cls} object at {hash:#x} ({self.osize}, {self.csize}, {self.usize})>" + return fmt.format(cls=type(self).__name__, + hash=id(self), + self=self) + @property def osize_fmt(self): return format_file_size(self.osize) diff --git a/borg/testsuite/helpers.py b/borg/testsuite/helpers.py index 37f6fcc4c..ac2cbacad 100644 --- a/borg/testsuite/helpers.py +++ b/borg/testsuite/helpers.py @@ -442,3 +442,5 @@ def test_stats_format(stats): """ s = "{0.osize_fmt}".format(stats) assert s == "10 B" + # kind of redundant, but id is variable so we can't match reliably + assert stats.__repr__() == ''.format(id(stats))