[pygobject] tests: Reorganize GError and GClosure tests
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] tests: Reorganize GError and GClosure tests
- Date: Mon, 4 Mar 2013 14:31:24 +0000 (UTC)
commit d50d16428edf42799489fe1befbc4ce56f0fa181
Author: Martin Pitt <martinpitt gnome org>
Date: Mon Mar 4 15:30:31 2013 +0100
tests: Reorganize GError and GClosure tests
Split TestGClosure.test_gclosure_in() into its three components.
Merge the various TestGError* classes into one, to match the structure of the
other tests.
tests/test_gi.py | 59 +++++++++++++++++++++++------------------------------
1 files changed, 26 insertions(+), 33 deletions(-)
---
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 27b3431..e51d7cf 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -1351,13 +1351,15 @@ class TestGValue(unittest.TestCase):
class TestGClosure(unittest.TestCase):
- def test_gclosure_in(self):
+ def test_in(self):
GIMarshallingTests.gclosure_in(lambda: 42)
+ def test_pass(self):
# test passing a closure between two C calls
closure = GIMarshallingTests.gclosure_return()
GIMarshallingTests.gclosure_in(closure)
+ def test_type_error(self):
self.assertRaises(TypeError, GIMarshallingTests.gclosure_in, 42)
self.assertRaises(TypeError, GIMarshallingTests.gclosure_in, None)
@@ -2228,21 +2230,8 @@ class TestMultiOutputArgs(unittest.TestCase):
self.assertEqual((6, 7), GIMarshallingTests.int_return_out())
-class TestGErrorException(unittest.TestCase):
- def test_gerror_exception(self):
- self.assertRaises(GObject.GError, GIMarshallingTests.gerror)
- try:
- GIMarshallingTests.gerror()
- except Exception:
- etype, e = sys.exc_info()[:2]
- self.assertEqual(e.domain, GIMarshallingTests.CONSTANT_GERROR_DOMAIN)
- self.assertEqual(e.code, GIMarshallingTests.CONSTANT_GERROR_CODE)
- self.assertEqual(e.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE)
-
-
# Interface
-
class TestInterfaces(unittest.TestCase):
class TestInterfaceImpl(GObject.GObject, GIMarshallingTests.Interface):
@@ -2452,19 +2441,17 @@ class TestDir(unittest.TestCase):
# self.assertTrue('DoNotImportDummyTests' in list)
-class TestGErrorArrayInCrash(unittest.TestCase):
- # Previously there was a bug in invoke, in which C arrays were unwrapped
- # from inside GArrays to be passed to the C function. But when a GError was
- # set, invoke would attempt to free the C array as if it were a GArray.
- # This crash is only for C arrays. It does not happen for C functions which
- # take in GArrays. See https://bugzilla.gnome.org/show_bug.cgi?id=642708
- def test_gerror_array_in_crash(self):
+class TestGError(unittest.TestCase):
+ def test_array_in_crash(self):
+ # Previously there was a bug in invoke, in which C arrays were unwrapped
+ # from inside GArrays to be passed to the C function. But when a GError was
+ # set, invoke would attempt to free the C array as if it were a GArray.
+ # This crash is only for C arrays. It does not happen for C functions which
+ # take in GArrays. See https://bugzilla.gnome.org/show_bug.cgi?id=642708
self.assertRaises(GObject.GError, GIMarshallingTests.gerror_array_in, [1, 2, 3])
-
-class TestGErrorOut(unittest.TestCase):
- # See https://bugzilla.gnome.org/show_bug.cgi?id=666098
- def test_gerror_out(self):
+ def test_out(self):
+ # See https://bugzilla.gnome.org/show_bug.cgi?id=666098
error, debug = GIMarshallingTests.gerror_out()
self.assertIsInstance(error, GObject.GError)
@@ -2473,10 +2460,8 @@ class TestGErrorOut(unittest.TestCase):
self.assertEqual(error.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE)
self.assertEqual(debug, GIMarshallingTests.CONSTANT_GERROR_DEBUG_MESSAGE)
-
-class TestGErrorOutTransferNone(unittest.TestCase):
- # See https://bugzilla.gnome.org/show_bug.cgi?id=666098
- def test_gerror_out_transfer_none(self):
+ def test_out_transfer_none(self):
+ # See https://bugzilla.gnome.org/show_bug.cgi?id=666098
error, debug = GIMarshallingTests.gerror_out_transfer_none()
self.assertIsInstance(error, GObject.GError)
@@ -2485,10 +2470,8 @@ class TestGErrorOutTransferNone(unittest.TestCase):
self.assertEqual(error.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE)
self.assertEqual(GIMarshallingTests.CONSTANT_GERROR_DEBUG_MESSAGE, debug)
-
-class TestGErrorReturn(unittest.TestCase):
- # See https://bugzilla.gnome.org/show_bug.cgi?id=666098
- def test_return_gerror(self):
+ def test_return(self):
+ # See https://bugzilla.gnome.org/show_bug.cgi?id=666098
error = GIMarshallingTests.gerror_return()
self.assertIsInstance(error, GObject.GError)
@@ -2496,6 +2479,16 @@ class TestGErrorReturn(unittest.TestCase):
self.assertEqual(error.code, GIMarshallingTests.CONSTANT_GERROR_CODE)
self.assertEqual(error.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE)
+ def test_exception(self):
+ self.assertRaises(GObject.GError, GIMarshallingTests.gerror)
+ try:
+ GIMarshallingTests.gerror()
+ except Exception:
+ etype, e = sys.exc_info()[:2]
+ self.assertEqual(e.domain, GIMarshallingTests.CONSTANT_GERROR_DOMAIN)
+ self.assertEqual(e.code, GIMarshallingTests.CONSTANT_GERROR_CODE)
+ self.assertEqual(e.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE)
+
class TestParamSpec(unittest.TestCase):
# https://bugzilla.gnome.org/show_bug.cgi?id=682355
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]