diff options
Diffstat (limited to 'tests/test_gi.py')
-rw-r--r-- | tests/test_gi.py | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/test_gi.py b/tests/test_gi.py index 4cdd1a4..1fbc216 100644 --- a/tests/test_gi.py +++ b/tests/test_gi.py @@ -1544,6 +1544,16 @@ class TestEnum(unittest.TestCase): gi._gi.enum_add, GIMarshallingTests.NoTypeFlags.__gtype__) + def test_type_module_name(self): + self.assertEqual(GIMarshallingTests.Enum.__name__, "Enum") + self.assertEqual(GIMarshallingTests.Enum.__module__, + "gi.repository.GIMarshallingTests") + + def test_repr(self): + self.assertEqual(repr(GIMarshallingTests.Enum.VALUE3), + "<enum GI_MARSHALLING_TESTS_ENUM_VALUE3 of type " + "GIMarshallingTests.Enum>") + class TestEnumVFuncResults(unittest.TestCase): class EnumTester(GIMarshallingTests.Object): @@ -1604,6 +1614,16 @@ class TestGEnum(unittest.TestCase): self.assertTrue(isinstance(genum, GIMarshallingTests.GEnum)) self.assertEqual(genum, GIMarshallingTests.GEnum.VALUE1) + def test_type_module_name(self): + self.assertEqual(GIMarshallingTests.GEnum.__name__, "GEnum") + self.assertEqual(GIMarshallingTests.GEnum.__module__, + "gi.repository.GIMarshallingTests") + + def test_repr(self): + self.assertEqual(repr(GIMarshallingTests.GEnum.VALUE3), + "<enum GI_MARSHALLING_TESTS_GENUM_VALUE3 of type " + "GIMarshallingTests.GEnum>") + class TestGFlags(unittest.TestCase): @@ -1657,6 +1677,16 @@ class TestGFlags(unittest.TestCase): self.assertTrue(isinstance(flags, GIMarshallingTests.Flags)) self.assertEqual(flags, GIMarshallingTests.Flags.VALUE1) + def test_type_module_name(self): + self.assertEqual(GIMarshallingTests.Flags.__name__, "Flags") + self.assertEqual(GIMarshallingTests.Flags.__module__, + "gi.repository.GIMarshallingTests") + + def test_repr(self): + self.assertEqual(repr(GIMarshallingTests.Flags.VALUE2), + "<flags GI_MARSHALLING_TESTS_FLAGS_VALUE2 of type " + "GIMarshallingTests.Flags>") + class TestNoTypeFlags(unittest.TestCase): @@ -1706,6 +1736,17 @@ class TestNoTypeFlags(unittest.TestCase): self.assertEqual(GIMarshallingTests.NoTypeFlags.__gtype__.name, 'PyGIMarshallingTestsNoTypeFlags') + def test_type_module_name(self): + self.assertEqual(GIMarshallingTests.NoTypeFlags.__name__, + "NoTypeFlags") + self.assertEqual(GIMarshallingTests.NoTypeFlags.__module__, + "gi.repository.GIMarshallingTests") + + def test_repr(self): + self.assertEqual(repr(GIMarshallingTests.NoTypeFlags.VALUE2), + "<flags GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2 of " + "type GIMarshallingTests.NoTypeFlags>") + class TestStructure(unittest.TestCase): @@ -1930,6 +1971,27 @@ class TestStructure(unittest.TestCase): self.assertRaises(TypeError, GIMarshallingTests.Union.method) + def test_repr(self): + self.assertRegexpMatches( + repr(GIMarshallingTests.PointerStruct()), + "<GIMarshallingTests.PointerStruct object at 0x[^\s]+ " + "\(void at 0x[^\s]+\)>") + + self.assertRegexpMatches( + repr(GIMarshallingTests.SimpleStruct()), + "<GIMarshallingTests.SimpleStruct object at 0x[^\s]+ " + "\(void at 0x[^\s]+\)>") + + self.assertRegexpMatches( + repr(GIMarshallingTests.Union()), + "<GIMarshallingTests.Union object at 0x[^\s]+ " + "\(GIMarshallingTestsUnion at 0x[^\s]+\)>") + + self.assertRegexpMatches( + repr(GIMarshallingTests.BoxedStruct()), + "<GIMarshallingTests.BoxedStruct object at 0x[^\s]+ " + "\(GIMarshallingTestsBoxedStruct at 0x[^\s]+\)>") + class TestGObject(unittest.TestCase): @@ -2060,6 +2122,18 @@ class TestGObject(unittest.TestCase): self.assertEqual(object_.__grefcount__, 1) self.assertEqual(new_object.__grefcount__, 1) + def test_repr(self): + self.assertRegexpMatches( + repr(GIMarshallingTests.Object(int=42)), + "<GIMarshallingTests.Object object at 0x[^\s]+ " + "\(GIMarshallingTestsObject at 0x[^\s]+\)>") + + def test_nongir_repr(self): + self.assertRegexpMatches( + repr(Gio.File.new_for_path("")), + "<__gi__.GLocalFile object at 0x[^\s]+ " + "\(GLocalFile at 0x[^\s]+\)>") + # FIXME: Doesn't actually return the same object. # def test_object_inout_same(self): # object_ = GIMarshallingTests.Object() |