[pygobject] tests: Add missing backwards compat methods for Python 2.6



commit 734979d0c8317201148a7e94a323225fba2d1635
Author: Martin Pitt <martinpitt gnome org>
Date:   Mon Jan 14 07:40:10 2013 +0100

    tests: Add missing backwards compat methods for Python 2.6
    
    Define skipIf(), assertLess(), and assertLessEqual() for running the tests with
    Python 2.6.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691646

 tests/runtests.py |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/tests/runtests.py b/tests/runtests.py
index 07b21e1..1bd1be0 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -18,6 +18,13 @@ if sys.version_info[:2] == (2, 6):
     unittest.skipUnless = skipUnless
     unittest.expectedFailure = lambda obj: obj
 
+    def skipIf(condition, reason):
+        if condition:
+            sys.stderr.write('[expected failure] ')
+        return lambda obj: obj
+
+    unittest.skipIf = skipUnless
+
     def assertGreater(self, a, b, msg=None):
         if not a > b:
             self.fail('%s not greater than %s' % (repr(a), repr(b)))
@@ -26,12 +33,22 @@ if sys.version_info[:2] == (2, 6):
         if not a >= b:
             self.fail('%s not greater than or equal to %s' % (repr(a), repr(b)))
 
+    def assertLess(self, a, b, msg=None):
+        if not a < b:
+            self.fail('%s not less than %s' % (repr(a), repr(b)))
+
+    def assertLessEqual(self, a, b, msg=None):
+        if not a <= b:
+            self.fail('%s not less than or equal to %s' % (repr(a), repr(b)))
+
     def assertIsInstance(self, obj, cls, msg=None):
         if not isinstance(obj, cls):
             self.fail('%s is not an instance of %r' % (repr(obj), cls))
 
     unittest.TestCase.assertGreaterEqual = assertGreaterEqual
     unittest.TestCase.assertGreater = assertGreater
+    unittest.TestCase.assertLessEqual = assertLessEqual
+    unittest.TestCase.assertLess = assertLess
     unittest.TestCase.assertIsInstance = assertIsInstance
 
 if sys.version_info[:2] == (2, 7):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]