]> granicus.if.org Git - python/commitdiff
Make some tests more verbose in the face of failure
authorBrett Cannon <brett@python.org>
Fri, 22 Nov 2013 18:22:22 +0000 (13:22 -0500)
committerBrett Cannon <brett@python.org>
Fri, 22 Nov 2013 18:22:22 +0000 (13:22 -0500)
Lib/test/test_module.py

index 536f7cf6326ccd5dd0b603d0d4a48668a4a1bee2..1230293670087b7964e592ff3b7971237c50bfba 100644 (file)
@@ -191,8 +191,12 @@ a = A(destroyed)"""
 
     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