Esempio n. 1
0
    def test_struct(self):
        s = GIMarshallingTests.NestedStruct()

        # FIXME: segfaults
        # https://bugzilla.gnome.org/show_bug.cgi?id=747002
        # s.simple_struct = None

        self.assertRaises(TypeError, setattr, s, "simple_struct", object())

        sub = GIMarshallingTests.SimpleStruct()
        sub.long_ = 42
        s.simple_struct = sub
        self.assertEqual(s.simple_struct.long_, 42)
Esempio n. 2
0
    def test_long(self):
        s = GIMarshallingTests.SimpleStruct()
        s.long_ = GLib.MAXLONG
        self.assertEqual(s.long_, GLib.MAXLONG)

        self.assertRaises(TypeError, setattr, s, "long_", b"a")
        self.assertRaises(TypeError, setattr, s, "long_", None)
        self.assertRaises(OverflowError, setattr, s, "long_", GLib.MAXLONG + 1)
        self.assertRaises(OverflowError, setattr, s, "long_", GLib.MINLONG - 1)

        s.long_ = 3.6
        self.assertEqual(s.long_, 3)

        s.long_ = Number(GLib.MINLONG)
        self.assertEqual(s.long_, GLib.MINLONG)