Improve debuggability of git cl tests.

Change-Id: If14776d86a687a6edf5917f2a63ff984b812ecb8
Reviewed-on: https://chromium-review.googlesource.com/432376
Reviewed-by: Sergiy Byelozyorov <sergiyb@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index 708368d..37de5c8 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -7,6 +7,7 @@
 
 import contextlib
 import json
+import logging
 import os
 import StringIO
 import sys
@@ -474,11 +475,26 @@
 
   def tearDown(self):
     try:
-      # Note: has_failed returns True if at least 1 test ran so far, current
-      # included, has failed. That means current test may have actually ran
-      # fine, and the check for no leftover calls would be skipped.
+      self.assertEquals([], self.calls)
+    except AssertionError:
       if not self.has_failed():
-        self.assertEquals([], self.calls)
+        raise
+      # Sadly, has_failed() returns True if this OR any other tests before this
+      # one have failed.
+      git_cl.logging.exception(
+          '\nIF YOU SEE THIS, READ BELOW, IT WILL SAVE YOUR TIME!\n'
+          'There are un-consumed self.calls after this test has finished.\n'
+          'If you don\'t know which test this is, run:\n'
+          '   tests/git_cl_tests.py -v\n'
+          '\n'
+          'If you are already running just this single test, then **first** '
+          'fix the problem whose exception is emitted below by unittest '
+          'runner.\n'
+          '\n'
+          'Else, to be sure what\'s going on, run this test **alone** with \n'
+          '    tests/git_cl_tests.py TestGitCl.<name>\n'
+          'and follow instructions above.\n' +
+          '=' * 80)
     finally:
       super(TestGitCl, self).tearDown()
 
@@ -2756,6 +2772,6 @@
 
 
 if __name__ == '__main__':
-  git_cl.logging.basicConfig(
-      level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR)
+  logging.basicConfig(
+      level=logging.DEBUG if '-v' in sys.argv else logging.ERROR)
   unittest.main()