[pygobject] tests: Move GError tests into test_error.py



commit 664bfa6fdf2196a0d1449baaca62a9a496121f67
Author: Simon Feltman <sfeltman src gnome org>
Date:   Sun May 4 23:14:27 2014 -0700

    tests: Move GError tests into test_error.py
    
    https://bugzilla.gnome.org/show_bug.cgi?id=712519

 tests/Makefile.am   |    1 +
 tests/test_error.py |   81 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/test_gi.py    |   49 -------------------------------
 3 files changed, 82 insertions(+), 49 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3468740..4094ce6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -84,6 +84,7 @@ EXTRA_DIST = \
        test-unknown.h \
        te_ST nouppera \
        org.gnome.test.gschema.xml \
+       test_error.py \
        test_gio.py \
        test_glib.py \
        test_gobject.py \
diff --git a/tests/test_error.py b/tests/test_error.py
new file mode 100644
index 0000000..a022fdd
--- /dev/null
+++ b/tests/test_error.py
@@ -0,0 +1,81 @@
+# -*- Mode: Python; py-indent-offset: 4 -*-
+# vim: tabstop=4 shiftwidth=4 expandtab
+#
+# test_error.py: Tests for GError wrapper implementation
+#
+# Copyright (C) 2012 Will Thompson
+# Copyright (C) 2013 Martin Pitt
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
+# USA
+
+import sys
+import unittest
+
+from gi.repository import GLib
+from gi.repository import GIMarshallingTests
+
+
+class TestMarshalling(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(GLib.GError, GIMarshallingTests.gerror_array_in, [1, 2, 3])
+
+    def test_out(self):
+        # See https://bugzilla.gnome.org/show_bug.cgi?id=666098
+        error, debug = GIMarshallingTests.gerror_out()
+
+        self.assertIsInstance(error, GLib.GError)
+        self.assertEqual(error.domain, GIMarshallingTests.CONSTANT_GERROR_DOMAIN)
+        self.assertEqual(error.code, GIMarshallingTests.CONSTANT_GERROR_CODE)
+        self.assertEqual(error.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE)
+        self.assertEqual(debug, GIMarshallingTests.CONSTANT_GERROR_DEBUG_MESSAGE)
+
+    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, GLib.GError)
+        self.assertEqual(error.domain, GIMarshallingTests.CONSTANT_GERROR_DOMAIN)
+        self.assertEqual(error.code, GIMarshallingTests.CONSTANT_GERROR_CODE)
+        self.assertEqual(error.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE)
+        self.assertEqual(GIMarshallingTests.CONSTANT_GERROR_DEBUG_MESSAGE, debug)
+
+    def test_return(self):
+        # See https://bugzilla.gnome.org/show_bug.cgi?id=666098
+        error = GIMarshallingTests.gerror_return()
+
+        self.assertIsInstance(error, GLib.GError)
+        self.assertEqual(error.domain, GIMarshallingTests.CONSTANT_GERROR_DOMAIN)
+        self.assertEqual(error.code, GIMarshallingTests.CONSTANT_GERROR_CODE)
+        self.assertEqual(error.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE)
+
+    def test_exception(self):
+        self.assertRaises(GLib.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)
+
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 628b645..31c0734 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -2551,55 +2551,6 @@ class TestDir(unittest.TestCase):
         # self.assertTrue('DoNotImportDummyTests' in list)
 
 
-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])
-
-    def test_out(self):
-        # See https://bugzilla.gnome.org/show_bug.cgi?id=666098
-        error, debug = GIMarshallingTests.gerror_out()
-
-        self.assertIsInstance(error, GObject.GError)
-        self.assertEqual(error.domain, GIMarshallingTests.CONSTANT_GERROR_DOMAIN)
-        self.assertEqual(error.code, GIMarshallingTests.CONSTANT_GERROR_CODE)
-        self.assertEqual(error.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE)
-        self.assertEqual(debug, GIMarshallingTests.CONSTANT_GERROR_DEBUG_MESSAGE)
-
-    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)
-        self.assertEqual(error.domain, GIMarshallingTests.CONSTANT_GERROR_DOMAIN)
-        self.assertEqual(error.code, GIMarshallingTests.CONSTANT_GERROR_CODE)
-        self.assertEqual(error.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE)
-        self.assertEqual(GIMarshallingTests.CONSTANT_GERROR_DEBUG_MESSAGE, debug)
-
-    def test_return(self):
-        # See https://bugzilla.gnome.org/show_bug.cgi?id=666098
-        error = GIMarshallingTests.gerror_return()
-
-        self.assertIsInstance(error, GObject.GError)
-        self.assertEqual(error.domain, GIMarshallingTests.CONSTANT_GERROR_DOMAIN)
-        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
     @unittest.expectedFailure


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