diff options
author | Martin Pitt <martinpitt@gnome.org> | 2012-11-14 09:27:42 +0100 |
---|---|---|
committer | Martin Pitt <martinpitt@gnome.org> | 2012-11-14 09:27:42 +0100 |
commit | 0c0fb8ef88a2c61cf95cd1cb96f6d5f296cad5fc (patch) | |
tree | 9f76e5f6e366e6d303512a3fa4b76efcbeb094e9 /tests/test_everything.py | |
parent | 84db7109dfbaf443758a5a4871ee385686d2703d (diff) | |
download | pygobject-0c0fb8ef88a2c61cf95cd1cb96f6d5f296cad5fc.tar.gz |
test_everything: Add test for callback returning wrong type
This covers the "expected a GVariant, got something else" check in
pyg_value_from_pyobject().
Diffstat (limited to 'tests/test_everything.py')
-rw-r--r-- | tests/test_everything.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_everything.py b/tests/test_everything.py index 26798f25..f1f14b7b 100644 --- a/tests/test_everything.py +++ b/tests/test_everything.py @@ -914,6 +914,22 @@ class TestClosures(unittest.TestCase): self.assertRaises(TypeError, Everything.test_closure_variant, callback, 'foo') self.assertFalse(self.called) + def test_variant_wrong_return_type(self): + def callback(variant): + return 'no_variant' + + # reset last error + sys.last_type = None + + # this does not directly raise an exception (see + # https://bugzilla.gnome.org/show_bug.cgi?id=616279) + result = Everything.test_closure_variant(callback, GLib.Variant('i', 42)) + # ... but the result shouldn't be a string + self.assertEqual(result, None) + # and the error should be shown + self.assertEqual(sys.last_type, TypeError) + self.assertTrue('return value' in str(sys.last_value), sys.last_value) + @unittest.skipUnless(has_cairo, 'built without cairo support') class TestProperties(unittest.TestCase): |