From 23cce79d9ff5ece3ea3fbf4a84b85eae088b0486 Mon Sep 17 00:00:00 2001 From: robk-tahoe Date: Mon, 20 Oct 2008 07:45:23 -0700 Subject: [PATCH] fuse/runtests: truncate expected file contents in reported error message this avoids dumping the repr of 1Mb of random data to stdout in the event of a test failure, but rather just dumps the start/end of the errant strings if the amount of data is > 200 chars repr'd --- contrib/fuse/runtests.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/contrib/fuse/runtests.py b/contrib/fuse/runtests.py index 756b8366..9f03bd8b 100644 --- a/contrib/fuse/runtests.py +++ b/contrib/fuse/runtests.py @@ -491,9 +491,15 @@ class SystemTest (object): def _check_write(self, testcap, name, expected_body): uploaded_body = self.get_file(testcap, name) + def drepr(obj): + r = repr(obj) + if len(r) > 200: + return r[:100] + ' ... ' + r[-100:] + else: + return r if uploaded_body != expected_body: - tmpl = 'Expected file contents %r but found %r' - raise TestFailure(tmpl, expected_body, uploaded_body) + tmpl = 'Expected file contents %s but found %s' + raise TestFailure(tmpl, drepr(expected_body), drepr(uploaded_body)) def test_write_overlapping_small_writes(self, testcap, testdir): self._write_test_overlap(testcap, testdir, name='large_overlap', bs=2**9, sz=2**20) -- 2.45.2