aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Rüger <mrueg@gentoo.org>2018-10-15 14:05:15 +0200
committerZac Medico <zmedico@gentoo.org>2018-10-28 10:09:41 -0700
commit7fced72de7ab6d17cb1b87b9b3fe7152ce2470ef (patch)
treeb29af9e7ea9e92428cf60800c8733f668251c211 /lib/portage/tests/__init__.py
parentrepoman.actions.Action._manifest_get: return True on success (diff)
downloadportage-7fced72de7ab6d17cb1b87b9b3fe7152ce2470ef.tar.gz
portage-7fced72de7ab6d17cb1b87b9b3fe7152ce2470ef.tar.bz2
portage-7fced72de7ab6d17cb1b87b9b3fe7152ce2470ef.zip
tests: Drop unittest skip shim
Python 2.6 is long gone, so clean up the code here Closes: https://github.com/gentoo/portage/pull/378 Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'lib/portage/tests/__init__.py')
-rw-r--r--lib/portage/tests/__init__.py36
1 files changed, 4 insertions, 32 deletions
diff --git a/lib/portage/tests/__init__.py b/lib/portage/tests/__init__.py
index e149b5c0c..84341ddae 100644
--- a/lib/portage/tests/__init__.py
+++ b/lib/portage/tests/__init__.py
@@ -9,18 +9,7 @@ import sys
import time
import unittest
-try:
- from unittest.runner import _TextTestResult # new in python-2.7
-except ImportError:
- from unittest import _TextTestResult
-
-try:
- # They added the skip framework to python-2.7.
- # Drop this once we drop python-2.6 support.
- unittest_skip_shims = False
- import unittest.SkipTest as SkipTest # new in python-2.7
-except ImportError:
- unittest_skip_shims = True
+from unittest.runner import TextTestResult as _TextTestResult
import portage
from portage import os
@@ -148,7 +137,7 @@ def getTests(path, base_path):
class TextTestResult(_TextTestResult):
"""
- We need a subclass of unittest._TextTestResult to handle tests with TODO
+ We need a subclass of unittest.runner.TextTestResult to handle tests with TODO
This just adds an addTodo method that can be used to add tests
that are marked TODO; these can be displayed later
@@ -213,7 +202,7 @@ class TestCase(unittest.TestCase):
self.setUp()
except KeyboardInterrupt:
raise
- except SkipTest:
+ except unittest.SkipTest:
raise
except Exception:
result.addError(self, sys.exc_info())
@@ -221,7 +210,7 @@ class TestCase(unittest.TestCase):
testMethod()
ok = True
- except SkipTest as e:
+ except unittest.SkipTest as e:
result.addPortageSkip(self, "%s: SKIP: %s" %
(testMethod, str(e)))
except self.failureException:
@@ -292,23 +281,6 @@ class TestCase(unittest.TestCase):
if os.path.exists(path):
raise self.failureException('path exists when it should not: %s' % path)
-if unittest_skip_shims:
- # Shim code for <python-2.7.
- class SkipTest(Exception):
- """unittest.SkipTest shim for <python-2.7"""
-
- def skipTest(self, reason):
- raise SkipTest(reason)
- setattr(TestCase, 'skipTest', skipTest)
-
- def assertIn(self, member, container, msg=None):
- self.assertTrue(member in container, msg=msg)
- setattr(TestCase, 'assertIn', assertIn)
-
- def assertNotIn(self, member, container, msg=None):
- self.assertFalse(member in container, msg=msg)
- setattr(TestCase, 'assertNotIn', assertNotIn)
-
class TextTestRunner(unittest.TextTestRunner):
"""
We subclass unittest.TextTestRunner to output SKIP for tests that fail but are skippable