diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-08-25 23:07:39 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-08-25 23:07:39 -0700 |
commit | ebc4f381f351f6c67dd911be1efa2df51de87f07 (patch) | |
tree | 78d41c3771d01d253eb703e88a8756f85c318645 | |
parent | 79a1d928f819692f22e28eeb0f8d780d13871fa4 (diff) | |
download | portage-ebc4f381f351f6c67dd911be1efa2df51de87f07.tar.gz portage-ebc4f381f351f6c67dd911be1efa2df51de87f07.tar.bz2 portage-ebc4f381f351f6c67dd911be1efa2df51de87f07.zip |
Add skipped test support (for python 2.6 compat)
Python supports skipped tests since 2.7, but we'll implement support
ourselves for python 2.6 compatibility. This is a simple extension of
the todo support that we have already implemented.
-rw-r--r-- | pym/portage/tests/__init__.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/pym/portage/tests/__init__.py b/pym/portage/tests/__init__.py index dddf3861f..6f21d10bd 100644 --- a/pym/portage/tests/__init__.py +++ b/pym/portage/tests/__init__.py @@ -109,6 +109,7 @@ class TextTestResult(_TextTestResult): def __init__(self, stream, descriptions, verbosity): super(TextTestResult, self).__init__(stream, descriptions, verbosity) self.todoed = [] + self.portage_skipped = [] def addTodo(self, test, info): self.todoed.append((test,info)) @@ -117,12 +118,20 @@ class TextTestResult(_TextTestResult): elif self.dots: self.stream.write(".") + def addPortageSkip(self, test, info): + self.portage_skipped.append((test,info)) + if self.showAll: + self.stream.writeln("SKIP") + elif self.dots: + self.stream.write(".") + def printErrors(self): if self.dots or self.showAll: self.stream.writeln() self.printErrorList('ERROR', self.errors) self.printErrorList('FAIL', self.failures) self.printErrorList('TODO', self.todoed) + self.printErrorList('SKIP', self.portage_skipped) class TestCase(unittest.TestCase): """ @@ -135,6 +144,7 @@ class TestCase(unittest.TestCase): def __init__(self, *pargs, **kwargs): unittest.TestCase.__init__(self, *pargs, **kwargs) self.todo = False + self.portage_skip = None def defaultTestResult(self): return TextTestResult() @@ -158,7 +168,13 @@ class TestCase(unittest.TestCase): testMethod() ok = True except self.failureException: - if self.todo: + if self.portage_skip is not None: + if self.portage_skip is True: + result.addPortageSkip(self, "%s: SKIP" % testMethod) + else: + result.addPortageSkip(self, "%s: SKIP: %s" % + (testMethod, self.portage_skip)) + elif self.todo: result.addTodo(self,"%s: TODO" % testMethod) else: result.addFailure(self, sys.exc_info()) |