[pygobject] Fix tests for Python 2
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Fix tests for Python 2
- Date: Tue, 31 Jul 2012 09:15:27 +0000 (UTC)
commit 7563bb9f8ed5740f52ddf0ca59daf7839853505b
Author: Martin Pitt <martinpitt gnome org>
Date: Tue Jul 31 11:14:36 2012 +0200
Fix tests for Python 2
In Python 2 we get different error messages for a mismatching self type. Fixes
check after commit 121b14028.
tests/test_gi.py | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 41fb5e7..3862334 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -1896,12 +1896,16 @@ class TestInterfaces(unittest.TestCase):
Gio.FileEnumerator.next_file(obj, None)
self.fail('call with wrong type argument unexpectedly succeeded')
except TypeError as e:
- # should have argument name
- self.assertTrue('self' in str(e), e)
- # should have expected type
- self.assertTrue('xpected Gio.FileEnumerator' in str(e), e)
- # should have actual type
- self.assertTrue('GIMarshallingTests.Object' in str(e), e)
+ if sys.version_info < (3, 0):
+ self.assertTrue('FileEnumerator' in str(e), e)
+ self.assertTrue('Object' in str(e), e)
+ else:
+ # should have argument name
+ self.assertTrue('self' in str(e), e)
+ # should have expected type
+ self.assertTrue('xpected Gio.FileEnumerator' in str(e), e)
+ # should have actual type
+ self.assertTrue('GIMarshallingTests.Object' in str(e), e)
# wrong type for first argument: GObject
var = GLib.Variant('s', 'mystring')
@@ -1922,12 +1926,16 @@ class TestInterfaces(unittest.TestCase):
Gio.SimpleAction.activate(obj, obj)
self.fail('call with wrong type argument unexpectedly succeeded')
except TypeError as e:
- # should have argument name
- self.assertTrue('self' in str(e), e)
- # should have expected type
- self.assertTrue('xpected Gio.Action' in str(e), e)
- # should have actual type
- self.assertTrue('GIMarshallingTests.Object' in str(e), e)
+ if sys.version_info < (3, 0):
+ self.assertTrue('SimpleAction' in str(e), e)
+ self.assertTrue('Object' in str(e), e)
+ else:
+ # should have argument name
+ self.assertTrue('self' in str(e), e)
+ # should have expected type
+ self.assertTrue('xpected Gio.Action' in str(e), e)
+ # should have actual type
+ self.assertTrue('GIMarshallingTests.Object' in str(e), e)
class TestInterfaceClash(unittest.TestCase):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]