[py-svn] r10764 - in py/dist/py/test: terminal testing

arigo at codespeak.net arigo at codespeak.net
Sun Apr 17 13:23:46 CEST 2005


Author: arigo
Date: Sun Apr 17 13:23:46 2005
New Revision: 10764

Modified:
   py/dist/py/test/terminal/terminal.py
   py/dist/py/test/testing/test_session.py
Log:
Refactored a bit the Terminal._processresult() method.


Modified: py/dist/py/test/terminal/terminal.py
==============================================================================
--- py/dist/py/test/terminal/terminal.py	(original)
+++ py/dist/py/test/terminal/terminal.py	Sun Apr 17 13:23:46 2005
@@ -84,12 +84,12 @@
                 self.out.line() 
             return
         else: 
-            restype, c = self._processresult(result)
             if self.config.option.verbose >= 1: 
-                resultstring = self.namemap.get(restype, result.__class__.__name__)
+                resultstring = self.repr_progress_long_result(colitem, result)
                 resultstring += " (%.2f)" % (colitem.elapsedtime,)
                 self.out.line(resultstring) 
-            else: 
+            else:
+                c = self.repr_progress_short_result(colitem, result)
                 self.out.write(c) 
 
     # -------------------
@@ -159,10 +159,17 @@
         Item.Failed: 'FAIL',
     }
 
-    def _processresult(self, testresult):
+    def repr_progress_short_result(self, item, testresult):
         for restype, char in self.typemap.items():
             if isinstance(testresult, restype):
-                return restype, char
+                return char
+        else:
+            raise TypeError, "not a result instance: %r" % testresult
+
+    def repr_progress_long_result(self, item, testresult):
+        for restype, char in self.namemap.items():
+            if isinstance(testresult, restype):
+                return char
         else:
             raise TypeError, "not a result instance: %r" % testresult
 

Modified: py/dist/py/test/testing/test_session.py
==============================================================================
--- py/dist/py/test/testing/test_session.py	(original)
+++ py/dist/py/test/testing/test_session.py	Sun Apr 17 13:23:46 2005
@@ -34,11 +34,11 @@
 
     def test_session_parsing(self): 
         config, args = py.test.Config.parse(['--session=terminal'])
-        assert config.getsessionclass() is py.test.TerminalSession 
+        assert issubclass(config.getsessionclass(), py.test.TerminalSession)
         config, args = py.test.Config.parse(['--session=tkinter'])
-        assert config.getsessionclass() is py.test.TkinterSession 
+        assert issubclass(config.getsessionclass(), py.test.TkinterSession)
         config, args = py.test.Config.parse(['--tkinter'])
-        assert config.getsessionclass() is py.test.TkinterSession 
+        assert issubclass(config.getsessionclass(), py.test.TkinterSession)
 
    
 #f = open('/tmp/logfile', 'wa')  



More information about the pytest-commit mailing list