[pypy-svn] r2714 - pypy/trunk/src/pypy/tool

sschwarzer at codespeak.net sschwarzer at codespeak.net
Wed Dec 31 22:42:16 CET 2003


Author: sschwarzer
Date: Wed Dec 31 22:42:16 2003
New Revision: 2714

Modified:
   pypy/trunk/src/pypy/tool/newtest.py
Log:
Added full name to TestItem and use this in __str__ and in printing
the "bad" test results in _print_results.


Modified: pypy/trunk/src/pypy/tool/newtest.py
==============================================================================
--- pypy/trunk/src/pypy/tool/newtest.py	(original)
+++ pypy/trunk/src/pypy/tool/newtest.py	Wed Dec 31 22:42:16 2003
@@ -313,6 +313,15 @@
             self.name = name or callable_.__name__
         except AttributeError:
             self.name = '<unnamed object>'
+        # - full name (including module and class, if applicable)
+        try:
+            parts = [self.module.__name__]
+        except AttributeError:
+            parts = []
+        if self.cls:
+            parts.append(self.cls.__name__)
+        parts.append(self.name)
+        self.full_name = '.'.join(parts)
         # - file
         try:
             if self.module is None:
@@ -433,11 +442,7 @@
         return result
 
     def __str__(self):
-        if self.cls is None:
-            return "TestItem from %s.%s" % (self.module.__name__, self.name)
-        else:
-            return "TestItem from %s.%s.%s" % (self.module.__name__,
-                                               self.cls.__name__, self.name)
+        return "TestItem from %s" % self.full_name
 
     def __repr__(self):
         return "<%s at %#x>" % (str(self), id(self))
@@ -618,12 +623,7 @@
         print 79 * '-'
         # print a line with the qualified name of the bad callable
         item = result.item
-        if result.item.cls is None:
-            print "%s.%s: %s" % (item.module.__name__, item.callable.__name__,
-                                 result.name.upper())
-        else:
-            print "%s.%s.%s: %s" % (item.module.__name__, item.cls.__name__,
-                                    item.callable.__name__, result.name.upper())
+        print "%s: %s" % (item.full_name, result.name.upper())
         print
         print result.formatted_traceback
     # emit a summary


More information about the Pypy-commit mailing list