diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-05-17 16:44:24 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-05-17 16:44:24 -0400 |
commit | 45357647d824817d8d55bfcf59defaec39240858 (patch) | |
tree | 550b2940288c414de0c0b1196688a204c09c22a8 /tests/backunittest.py | |
parent | f5c6fd96beb04ccd7a86817ad5be1163f8409420 (diff) | |
download | python-coveragepy-git-45357647d824817d8d55bfcf59defaec39240858.tar.gz |
Some day I will remember to fix pylint things before I check in the code.
Diffstat (limited to 'tests/backunittest.py')
-rw-r--r-- | tests/backunittest.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/tests/backunittest.py b/tests/backunittest.py index a4377b0b..6498397f 100644 --- a/tests/backunittest.py +++ b/tests/backunittest.py @@ -8,9 +8,9 @@ except ImportError: import unittest -def _need(method): - """Do we need to define our own `method` method?""" - return not hasattr(unittest.TestCase, method) +def unittest_has(method): + """Does `unitttest.TestCase` have `method` defined?""" + return hasattr(unittest.TestCase, method) class TestCase(unittest.TestCase): @@ -20,21 +20,22 @@ class TestCase(unittest.TestCase): `unittest` doesn't have them. """ - if _need('assertCountEqual'): - try: - assertCountEqual = assertSameElements - except NameError: + # pylint: disable=missing-docstring + + if not unittest_has('assertCountEqual'): + if unittest_has('assertSameElements'): + def assertCountEqual(self, *args, **kwargs): + # pylint: disable=no-member + return self.assertSameElements(*args, **kwargs) + else: def assertCountEqual(self, s1, s2): """Assert these have the same elements, regardless of order.""" self.assertEqual(set(s1), set(s2)) - else: - def assertCountEqual(self, *args, **kwargs): - return self.assertSameElements(*args, **kwargs) - if _need('assertRaisesRegex'): + if not unittest_has('assertRaisesRegex'): def assertRaisesRegex(self, *args, **kwargs): return self.assertRaisesRegexp(*args, **kwargs) - if _need('assertRegex'): + if not unittest_has('assertRegex'): def assertRegex(self, *args, **kwargs): return self.assertRegexpMatches(*args, **kwargs) |