[pygobject/py3k] Make the option callback failure selftest work with both Python 2 and 3



commit deab7a70d92c19ccdb05c5180cdd84cd460650bd
Author: David Malcolm <dmalcolm redhat com>
Date:   Fri Apr 16 13:15:32 2010 -0400

    Make the option callback failure selftest work with both Python 2 and 3
    
    StandardError went away in Python 3; use Exception instead, as it ought to
    work with both Python 2 and Python 3

 tests/test_option.py |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/tests/test_option.py b/tests/test_option.py
index ad5f1b3..beb55bf 100644
--- a/tests/test_option.py
+++ b/tests/test_option.py
@@ -26,7 +26,7 @@ class TestOption(unittest.TestCase):
 
     def _create_group(self):
         def option_callback(option, opt, value, parser):
-            raise StandardError(self.EXCEPTION_MESSAGE)
+            raise Exception(self.EXCEPTION_MESSAGE)
 
         group = OptionGroup(
             "unittest", "Unit test options", "Show all unittest options",
@@ -101,7 +101,7 @@ class TestOption(unittest.TestCase):
     def testOptionGroupConstructor(self):
         self.assertRaises(TypeError, OptionGroup)
 
-    def testStandardError(self):
+    def testCallbackFailure(self):
         self._create_group()
         sio = StringIO()
         old_stderr = sys.stderr
@@ -111,6 +111,7 @@ class TestOption(unittest.TestCase):
                 ["test_option.py", "--callback-failure-test"])
         finally:
             sys.stderr = old_stderr
-        assert (sio.getvalue().split('\n')[-2] ==
-                "StandardError: " + self.EXCEPTION_MESSAGE)
+
+        self.assertEquals(sio.getvalue().split('\n')[-2],
+                          'Exception: ' + self.EXCEPTION_MESSAGE)
 



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