From: robk-tahoe Date: Mon, 20 Oct 2008 14:45:23 +0000 (-0700) Subject: fuse/runtests: truncate expected file contents in reported error message X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/frontends/install.html?a=commitdiff_plain;h=23cce79d9ff5ece3ea3fbf4a84b85eae088b0486;p=tahoe-lafs%2Ftahoe-lafs.git 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 --- 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)