eric7/DebugClients/Python/coverage/backunittest.py

branch
eric7
changeset 8527
2bd1325d727e
parent 8526
587202572b10
child 8528
2175f268ad9b
equal deleted inserted replaced
8526:587202572b10 8527:2bd1325d727e
1 # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2 # For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
3
4 """Implementations of unittest features from the future."""
5
6 import unittest
7
8
9 def unittest_has(method):
10 """Does `unittest.TestCase` have `method` defined?"""
11 return hasattr(unittest.TestCase, method)
12
13
14 class TestCase(unittest.TestCase):
15 """Just like unittest.TestCase, but with assert methods added.
16
17 Designed to be compatible with 3.1 unittest. Methods are only defined if
18 `unittest` doesn't have them.
19
20 """
21 # pylint: disable=signature-differs, deprecated-method
22
23 if not unittest_has('assertCountEqual'):
24 def assertCountEqual(self, *args, **kwargs):
25 return self.assertItemsEqual(*args, **kwargs)
26
27 if not unittest_has('assertRaisesRegex'):
28 def assertRaisesRegex(self, *args, **kwargs):
29 return self.assertRaisesRegexp(*args, **kwargs)
30
31 if not unittest_has('assertRegex'):
32 def assertRegex(self, *args, **kwargs):
33 return self.assertRegexpMatches(*args, **kwargs)

eric ide

mercurial