[pygobject] Move existing repository tests into test_repository



commit 314c933626c4dc5fc585d0e5b6c45ddb17c2e52f
Author: Simon Feltman <sfeltman src gnome org>
Date:   Fri Oct 4 20:43:02 2013 -0700

    Move existing repository tests into test_repository
    
    Move flags and enum double registration tests into test_repository.py.
    Remove duplicate ObjectInfo tests from test_gi.py.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709008

 tests/test_gi.py         |   38 --------------------------------------
 tests/test_repository.py |   28 ++++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 38 deletions(-)
---
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 8cb1c12..19f56d2 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -1479,17 +1479,6 @@ class TestEnum(unittest.TestCase):
         self.assertEqual(GIMarshallingTests.Enum.__gtype__.name,
                          'PyGIMarshallingTestsEnum')
 
-    def test_enum_double_registration_error(self):
-        # a warning is printed for double registration and pygobject will
-        # also raise a RuntimeError.
-        old_mask = GLib.log_set_always_fatal(GLib.LogLevelFlags.LEVEL_ERROR)
-        try:
-            self.assertRaises(RuntimeError,
-                              gi._gi.enum_register_new_gtype_and_add,
-                              GIMarshallingTests.Enum.__info__)
-        finally:
-            GLib.log_set_always_fatal(old_mask)
-
     def test_enum_add_type_error(self):
         self.assertRaises(TypeError,
                           gi._gi.enum_add,
@@ -1648,17 +1637,6 @@ class TestNoTypeFlags(unittest.TestCase):
         self.assertEqual(GIMarshallingTests.NoTypeFlags.__gtype__.name,
                          'PyGIMarshallingTestsNoTypeFlags')
 
-    def test_flags_double_registration_error(self):
-        # a warning is printed for double registration and pygobject will
-        # also raise a RuntimeError.
-        old_mask = GLib.log_set_always_fatal(GLib.LogLevelFlags.LEVEL_ERROR)
-        try:
-            self.assertRaises(RuntimeError,
-                              gi._gi.flags_register_new_gtype_and_add,
-                              GIMarshallingTests.NoTypeFlags.__info__)
-        finally:
-            GLib.log_set_always_fatal(old_mask)
-
 
 class TestStructure(unittest.TestCase):
 
@@ -2957,22 +2935,6 @@ class TestProjectVersion(unittest.TestCase):
         gi.check_version("3.3.5")
 
 
-class TestObjectInfo(unittest.TestCase):
-    def test_get_abstract_with_abstract(self):
-        repo = gi.gi.Repository.get_default()
-        info = repo.find_by_name('GObject', 'TypeModule')
-        self.assertTrue(info.get_abstract())
-
-    def test_get_abstract_with_concrete(self):
-        repo = gi.gi.Repository.get_default()
-        info = repo.find_by_name('GObject', 'Object')
-        self.assertFalse(info.get_abstract())
-
-    def test_get_class_struct(self):
-        self.assertEqual(GObject.Object.__info__.get_class_struct(),
-                         GObject.ObjectClass.__info__)
-
-
 class TestDeprecation(unittest.TestCase):
     def test_method(self):
         d = GLib.Date.new()
diff --git a/tests/test_repository.py b/tests/test_repository.py
index 2f121c0..76d4417 100644
--- a/tests/test_repository.py
+++ b/tests/test_repository.py
@@ -26,6 +26,8 @@ import collections
 import gi._gi as GIRepository
 from gi.module import repository as repo
 from gi.repository import GObject
+from gi.repository import GLib
+from gi.repository import GIMarshallingTests
 
 try:
     import cairo
@@ -165,6 +167,32 @@ class Test(unittest.TestCase):
         self.assertEqual(vfunc.get_name(), 'vfunc_return_value_only')
         self.assertEqual(vfunc.get_invoker(), invoker)
 
+    def test_flags_double_registration_error(self):
+        # a warning is printed for double registration and pygobject will
+        # also raise a RuntimeError.
+        GIMarshallingTests.NoTypeFlags  # cause flags registration
+        info = repo.find_by_name('GIMarshallingTests', 'NoTypeFlags')
+        old_mask = GLib.log_set_always_fatal(GLib.LogLevelFlags.LEVEL_ERROR)
+        try:
+            self.assertRaises(RuntimeError,
+                              GIRepository.flags_register_new_gtype_and_add,
+                              info)
+        finally:
+            GLib.log_set_always_fatal(old_mask)
+
+    def test_enum_double_registration_error(self):
+        # a warning is printed for double registration and pygobject will
+        # also raise a RuntimeError.
+        GIMarshallingTests.Enum  # cause enum registration
+        info = repo.find_by_name('GIMarshallingTests', 'Enum')
+        old_mask = GLib.log_set_always_fatal(GLib.LogLevelFlags.LEVEL_ERROR)
+        try:
+            self.assertRaises(RuntimeError,
+                              GIRepository.enum_register_new_gtype_and_add,
+                              info)
+        finally:
+            GLib.log_set_always_fatal(old_mask)
+
 
 if __name__ == '__main__':
     unittest.main()


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