diff options
author | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-04-11 16:43:52 +0200 |
---|---|---|
committer | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-04-11 16:43:52 +0200 |
commit | bfbceea1bd99eb90cdd5c75b68b2e3a158a289f8 (patch) | |
tree | 987529de71efabdf9a67073738089f8d4b4c2575 | |
parent | a26c6b7ef7b54b5baff421b4d59ad1f062c0a670 (diff) | |
download | psutil-bfbceea1bd99eb90cdd5c75b68b2e3a158a289f8.tar.gz |
change fetch all test suite so that it does not exit at the first failure; instead collect all failures after calling all methods and fail at the end by presenting an indented and detailed error message including all the tests which went wrong
-rw-r--r-- | test/test_psutil.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/test/test_psutil.py b/test/test_psutil.py index d9594205..5b0b9b8d 100644 --- a/test/test_psutil.py +++ b/test/test_psutil.py @@ -1705,8 +1705,11 @@ class TestFetchAllProcesses(unittest.TestCase): continue attrs.append(name) - for p in psutil.process_iter(): - for name in attrs: + default = object() + failures = [] + for name in attrs: + for p in psutil.process_iter(): + ret = default try: try: attr = getattr(p, name, None) @@ -1731,9 +1734,19 @@ class TestFetchAllProcesses(unittest.TestCase): meth(ret) except Exception: err = sys.exc_info()[1] - trace = traceback.format_exc() - self.fail('%s\nproc=%s, method=%r, retvalue=%r' - % (trace, p, name, ret)) + s = '\n' + '=' * 70 + '\n' + s += "FAIL: test_%s (proc=%s" % (name, p) + if ret != default: + s += ", ret=%s)" % repr(ret) + s += ')\n' + s += '-' * 70 + s += "\n%s" % traceback.format_exc() + s = "\n".join((" " * 4) + i for i in s.splitlines()) + failures.append(s) + break + + if failures: + self.fail(''.join(failures)) # we should always have a non-empty list, not including PID 0 etc. # special cases. |