[pygobject] Fix exception test case for Python 2



commit 1e1f5b2f2f15547c1f2cbc948d2b764bd0a37c44
Author: Martin Pitt <martinpitt gnome org>
Date:   Mon Sep 3 21:57:00 2012 +0200

    Fix exception test case for Python 2
    
    Regression from commit 77844c5 which did not work with Python 2.

 tests/test_everything.py |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/tests/test_everything.py b/tests/test_everything.py
index 406fcb3..c5140ed 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -234,11 +234,13 @@ class TestEverything(unittest.TestCase):
         try:
             Everything.TestBoxedPrivate()
             self.fail('allocating disguised struct without default constructor unexpectedly succeeded')
-        except TypeError as e:
-            self.assertTrue('TestBoxedPrivate' in str(e), str(e))
-            self.assertTrue('override' in str(e), str(e))
-            self.assertTrue('constructor' in str(e), str(e))
-            tb = ''.join(traceback.format_exception(type(e), e, e.__traceback__))
+        except TypeError:
+            (e_type, e_value, e_tb) = sys.exc_info()
+            self.assertEqual(e_type, TypeError)
+            self.assertTrue('TestBoxedPrivate' in str(e_value), str(e_value))
+            self.assertTrue('override' in str(e_value), str(e_value))
+            self.assertTrue('constructor' in str(e_value), str(e_value))
+            tb = ''.join(traceback.format_exception(e_type, e_value, e_tb))
             self.assertTrue('tests/test_everything.py", line' in tb, tb)
 
 



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