From dedfe2dcd4627546c52f4620393324f7ab57a55a Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 13 Aug 2019 08:29:50 +0300 Subject: [PATCH] unittest: Add assertLessEqual, assertGreaterEqual methods. As used by CPython testsuite. --- python-stdlib/unittest/unittest.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python-stdlib/unittest/unittest.py b/python-stdlib/unittest/unittest.py index 061a0b0b..a22880d5 100644 --- a/python-stdlib/unittest/unittest.py +++ b/python-stdlib/unittest/unittest.py @@ -43,6 +43,16 @@ class TestCase: msg = "%r not expected to be equal %r" % (x, y) assert x != y, msg + def assertLessEqual(self, x, y, msg=None): + if msg is None: + msg = "%r is expected to be <= %r" % (x, y) + assert x <= y, msg + + def assertGreaterEqual(self, x, y, msg=None): + if msg is None: + msg = "%r is expected to be >= %r" % (x, y) + assert x >= y, msg + def assertAlmostEqual(self, x, y, places=None, msg="", delta=None): if x == y: return