aboutsummaryrefslogtreecommitdiffstats
path: root/repoman
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 /repoman
parentrepoman.actions.Action._manifest_get: return True on success (diff)
downloadgentoo-portage-7fced72de7ab6d17cb1b87b9b3fe7152ce2470ef.tar.xz
gentoo-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 'repoman')
-rw-r--r--repoman/lib/repoman/tests/__init__.py34
1 files changed, 3 insertions, 31 deletions
diff --git a/repoman/lib/repoman/tests/__init__.py b/repoman/lib/repoman/tests/__init__.py
index d57ca9b1085..48c52c4993c 100644
--- a/repoman/lib/repoman/tests/__init__.py
+++ b/repoman/lib/repoman/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 repoman
from repoman import REPOMAN_BASE_PATH
@@ -152,7 +141,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
@@ -225,7 +214,7 @@ class TestCase(unittest.TestCase):
try:
testMethod()
ok = True
- except SkipTest as e:
+ except unittest.SkipTest as e:
result.addPortageSkip(self, "%s: SKIP: %s" %
(testMethod, str(e)))
except self.failureException:
@@ -296,23 +285,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