[pygobject/gsoc2009: 86/160] Refactore enum tests and add one for flags



commit b6d3c9e7b9695aca450d2518b4531987e340cc62
Author: Simon van der Linden <svdlinden src gnome org>
Date:   Fri Jul 31 13:01:41 2009 +0200

    Refactore enum tests and add one for flags

 tests/test_girepository.py |   32 +++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/tests/test_girepository.py b/tests/test_girepository.py
index edcb44e..7e3e74b 100644
--- a/tests/test_girepository.py
+++ b/tests/test_girepository.py
@@ -494,10 +494,36 @@ class TestGIEverything(unittest.TestCase):
     def testValueReturn(self):
         self.assertEquals(42, Everything.test_value_return(42))
 
+
+# Enum
+
     def testEnum(self):
-        self.assertEqual('value1', Everything.test_enum_param(Everything.TestEnum.VALUE1))
-        self.assertEqual('value2', Everything.test_enum_param(Everything.TestEnum.VALUE2))
-        self.assertEqual('value3', Everything.test_enum_param(Everything.TestEnum.VALUE3))
+        self.assertTrue(issubclass(Everything.TestEnum, gobject.GEnum))
+
+        # Test instantiation.
+        self.assertTrue(isinstance(Everything.TestEnum(42), Everything.TestEnum))
+
+        # Test attributes.
+        self.assertTrue(isinstance(Everything.TestEnum.VALUE3, Everything.TestEnum))
+
+        # Test numeric equivalence.
+        self.assertEquals(Everything.TestEnum.VALUE3, 42)
+
+
+# Flags
+
+    def testFlags(self):
+        self.assertTrue(issubclass(Everything.TestFlags, gobject.GFlags))
+
+        # Test instantiation.
+        self.assertTrue(isinstance(Everything.TestFlags(1 << 2), Everything.TestFlags))
+
+        # Test attributes.
+        self.assertTrue(isinstance(Everything.TestFlags.FLAG3, Everything.TestFlags))
+
+        # Test numeric equivalence.
+        self.assertEquals(Everything.TestFlags.FLAG3, 1 << 2)
+
 
     def testSignal(self):
         h = SignalHandler()



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