[Python-checkins] cpython: Make some tests more verbose in the face of failure

brett.cannon python-checkins at python.org
Fri Nov 22 19:22:24 CET 2013


http://hg.python.org/cpython/rev/9621a37f069f
changeset:   87356:9621a37f069f
user:        Brett Cannon <brett at python.org>
date:        Fri Nov 22 13:22:22 2013 -0500
summary:
  Make some tests more verbose in the face of failure

files:
  Lib/test/test_module.py |  8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py
--- a/Lib/test/test_module.py
+++ b/Lib/test/test_module.py
@@ -191,8 +191,12 @@
 
     def test_module_repr_source(self):
         r = repr(unittest)
-        self.assertEqual(r[:25], "<module 'unittest' from '")
-        self.assertEqual(r[-13:], "__init__.py'>")
+        starts_with = "<module 'unittest' from '"
+        ends_with = "__init__.py'>"
+        self.assertEqual(r[:len(starts_with)], starts_with,
+                         '{!r} does not start with {!r}'.format(r, starts_with))
+        self.assertEqual(r[-len(ends_with):], ends_with,
+                         '{!r} does not end with {!r}'.format(r, ends_with))
 
     def test_module_finalization_at_shutdown(self):
         # Module globals and builtins should still be available during shutdown

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list