Take marien's advice, turn Skips into Todos for clarity sake
authorAlec Warner <antarus@gentoo.org>
Wed, 7 Mar 2007 04:27:18 +0000 (04:27 -0000)
committerAlec Warner <antarus@gentoo.org>
Wed, 7 Mar 2007 04:27:18 +0000 (04:27 -0000)
svn path=/main/trunk/; revision=6189

pym/portage/tests/__init__.py
pym/portage/tests/dep/test_isvalidatom.py

index 56fc869c2beabe99d4875b53bbbb6acf9c1cfce8..159e67b63bf666016f42087306e76f6b55dfe0c9 100644 (file)
@@ -46,27 +46,23 @@ def getTests( path, base_path ):
                        raise
        return result
 
-class SkipException(Exception):
-       pass
-
 class TextTestResult(unittest._TextTestResult):
        """
-       We need a subclass of unittest._TextTestResult to handle skipped
-       tests.
+       We need a subclass of unittest._TextTestResult to handle tests with TODO
 
-       This just adds an addSkip method that can be used to add
-       skipped tests to the result; these can be displayed later
+       This just adds an addTodo method that can be used to add tests
+       that are marked TODO; these can be displayed later
        by the test runner.
        """
        
        def __init__( self, stream, descriptions, verbosity ):
                unittest._TextTestResult.__init__( self, stream, descriptions, verbosity )
-               self.skipped = []
+               self.todoed = []
 
-       def addSkip( self, test, info ):
-               self.skipped.append((test,info))
+       def addTodo( self, test, info ):
+               self.todoed.append((test,info))
                if self.showAll:
-                       self.stream.writeln("FAIL AND SKIP")
+                       self.stream.writeln("TODO")
                elif self.dots:
                        self.stream.write(".")
        
@@ -75,7 +71,7 @@ class TextTestResult(unittest._TextTestResult):
                        self.stream.writeln()
                        self.printErrorList('ERROR', self.errors)
                        self.printErrorList('FAIL', self.failures)
-                       self.printErrorList('SKIP', self.skipped)
+                       self.printErrorList('TODO', self.todoed)
        
 class TestCase(unittest.TestCase):
        """
@@ -85,8 +81,6 @@ class TestCase(unittest.TestCase):
        (broken code!!??!11oneone) but it does happen at times.
        """
        
-       SkipException = SkipException
-       
        def __init__(self, methodName='runTest'):
                # This method exists because unittest.py in python 2.4 stores
                # the methodName as __testMethodName while 2.5 uses
@@ -114,9 +108,10 @@ class TestCase(unittest.TestCase):
                                testMethod()
                                ok = True
                        except self.failureException:
-                               result.addFailure(self, self._exc_info())
-                       except self.SkipException:
-                               result.addSkip(self,"%s: Failed but Skippable" % testMethod)
+                               if self.todo:
+                                       result.addTodo(self,"%s: TODO" % testMethod)
+                               else:
+                                       result.addFailure(self, self._exc_info())
                        except KeyboardInterrupt:
                                raise
                        except:
index 5f0149120f736b76878d1cc3a91238a4cf8f4530..35f7160b79a8aa97039bba6afbaace1cc97b5704 100644 (file)
@@ -12,6 +12,8 @@ class IsValidAtom(TestCase):
        """ A simple testcase for isvalidatom
        """
 
+       todo = True
+
        def testIsValidAtom(self):
                
                tests = [ ( "sys-apps/portage", True ),
@@ -33,7 +35,6 @@ class IsValidAtom(TestCase):
                          ( "portage", False ) ]
 
                for test in tests:
-                       raise self.SkipException()
                        if test[1]:
                                atom_type = "valid"
                        else: