Ejemplo n.º 1
0
    def test_props_gstrv(self):
        from pgi.repository import GUdev

        repo = Repository("GUdev", "1.0")
        GUdev.Client.props.subsystems
        self.assertEqual(repo.parse_properties(GUdev.Client)[0].type_desc,
                         "[:obj:`str`]")
Ejemplo n.º 2
0
    def test_atk(self):
        repo = Repository("Atk", "1.0")
        Atk = repo.import_module()

        c = Constant.from_object(repo, "", "FOO", Atk.Document.__gtype__)
        self.assertEqual(str(c.value), "<GType AtkDocument>")

        klass = Class.from_object(repo, Atk.Document)
        method = find(klass.methods, "get_attributes")
        self.assertEqual(method.info.version_added, "1.12")

        method = find(klass.methods, "get_attribute_value")
        self.assertEqual(method.info.version_added, "1.12")

        klass = Class.from_object(repo, Atk.Hyperlink)

        method = find(klass.methods, "is_selected_link")
        self.assertTrue(method.info.deprecated)
        self.assertEqual(method.info.version_added, "1.4")
        self.assertEqual(method.info.version_deprecated, "1.8")
        self.assertTrue(method.info.deprecation_desc, "1.8")

        klass = Flags.from_object(repo, Atk.Role)
        info = find(klass.values, "APPLICATION").info
        self.assertEqual(info.version_added, "1.1.4")
Ejemplo n.º 3
0
    def test_version_added(self):
        repo = Repository("Atk", "1.0")
        docs = repo.lookup_attr_meta("Atk.Document.get_attributes")
        self.assertTrue(".. versionadded:: 1.12" in docs)

        docs = repo.lookup_attr_meta("Atk.Document.get_attribute_value")
        self.assertTrue(".. versionadded:: 1.12" in docs)
Ejemplo n.º 4
0
    def test_gtk(self):
        repo = Repository("Gtk", "3.0")
        Gtk = repo.import_module()

        klass = Class.from_object(repo, Gtk.TreeModel)
        vfunc = find(klass.vfuncs, "do_get_iter")
        self.assertTrue(vfunc.info.desc)

        Class.from_object(repo, Gtk.Button)
        Class.from_object(repo, Gtk.Paned)
        Class.from_object(repo, Gtk.ActionBar)

        klass = Class.from_object(repo, Gtk.TextView)
        self.assertTrue(klass.image_path)

        klass = Class.from_object(repo, Gtk.Widget)
        translate_coordinates = find(klass.methods, "translate_coordinates")
        # make sure we replace src_widget with self
        self.assertTrue("src_widget" not in translate_coordinates.info.desc)

        mod = repo.parse()
        find(mod.class_structures, "WidgetClass")
        find(mod.structures, "TableChild")
        self.assertRaises(
            LookupError, find, mod.class_structures, "TableChild")
        self.assertRaises(
            LookupError, find, mod.structures, "WidgetClass")
Ejemplo n.º 5
0
    def test_glib(self):
        repo = Repository("GLib", "2.0")
        mod = repo.parse()

        klass = find(mod.pyclasses, "Error")

        # GLib.io_add_watch points to g_io_add_watch_full and should
        # also use its docs
        func = find(mod.functions, "io_add_watch")
        self.assertTrue(":param priority:" in func.signature_desc)

        # we include a note containing the shadowed docs
        self.assertTrue(func.info.shadowed_desc)

        self.assertEqual(repo.get_shadowed("g_idle_add"), "g_idle_add_full")

        self.assertEqual(repo.lookup_py_id("g_idle_add"), "GLib.idle_add")
        self.assertEqual(repo.lookup_py_id("g_idle_add", shadowed=False), None)

        klass = find(mod.enums, "BookmarkFileError")
        self.assertEqual(klass.base, "GLib.Enum")

        klass = find(mod.enums, "Enum")
        self.assertEqual(klass.base, None)

        klass = find(mod.flags, "FileTest")
        self.assertEqual(klass.base, "GLib.Flags")

        klass = find(mod.flags, "Flags")
        self.assertEqual(klass.base, None)

        struct = find(mod.structures, "MemVTable")
        field = find(struct.fields, "realloc")
        self.assertTrue("object" in field.type_desc)
Ejemplo n.º 6
0
 def test_method_inheritance(self):
     repo = Repository("Atk", "1.0")
     Atk = repo.import_module()
     klass = Class.from_object(repo, Atk.Plug)
     self.assertEqual(
         [x[0] for x in klass.methods_inherited],
         ['Atk.Object', 'GObject.Object', 'Atk.Component']
     )
Ejemplo n.º 7
0
 def test_method_inheritance(self):
     repo = Repository("Atk", "1.0")
     Atk = repo.import_module()
     klass = Class.from_object(repo, Atk.Plug)
     self.assertEqual(
         klass.methods_inherited,
         [('Atk.Object', 23),
          ('GObject.Object', 33),
          ('Atk.Component', 13)])
Ejemplo n.º 8
0
    def test_hierarchy(self):
        from pgi.repository import GObject

        repo = Repository("Atk", "1.0")
        Atk = repo.import_module()
        hier = get_hierarchy([Atk.NoOpObjectFactory])
        self.assertEqual(hier.keys(), [GObject.Object])
        self.assertEqual(hier[GObject.Object].keys(), [Atk.ObjectFactory])
        self.assertEqual(hier[GObject.Object][Atk.ObjectFactory].keys(), [Atk.NoOpObjectFactory])
        self.assertFalse(hier[GObject.Object][Atk.ObjectFactory][Atk.NoOpObjectFactory])
Ejemplo n.º 9
0
    def test_gtk_overrides(self):
        repo = Repository("Gtk", "3.0")
        Gtk = repo.import_module()

        PyClass.from_object(repo, Gtk.TreeModelRow)
        PyClass.from_object(repo, Gtk.TreeModelRowIter)

        func = Function.from_object("Gtk.Container", "child_get", Gtk.Container.child_get, repo, Gtk.Container)
        self.assertEqual(func.info.desc, "Returns a list of child property values for the given names.")
        self.assertEqual(func.signature, "(child, *prop_names)")

        func = Function.from_object("Gtk", "stock_lookup", Gtk.stock_lookup, repo, Gtk)
        self.assertEqual(func.signature, "(stock_id)")
Ejemplo n.º 10
0
    def test_pango(self):
        repo = Repository("Pango", "1.0")
        mod = repo.parse()
        func = find(mod.functions, "extents_to_pixels")
        self.assertTrue(":param inclusive:" in func.signature_desc)

        func = find(mod.functions, "break_")
        self.assertTrue(":param text:" in func.signature_desc)

        func = find(find(mod.structures, "TabArray").methods, "new")
        self.assertTrue(":param initial_size:" in func.signature_desc)

        self.assertTrue(repo.is_private("Pango.RendererPrivate"))
        self.assertFalse(repo.is_private("Pango.AttrIterator"))
Ejemplo n.º 11
0
    def test_glib(self):
        repo = Repository("GLib", "2.0")
        mod = repo.parse()

        # GLib.io_add_watch points to g_io_add_watch_full and should
        # also use its docs
        func = find(mod.functions, "io_add_watch")
        self.assertTrue(":param priority:" in func.signature_desc)

        # we include a note containing the shadowed docs
        self.assertTrue(func.info.shadowed_desc)

        klass = find(mod.structures, "IConv")
        func = find(klass.methods, "_")
        self.assertTrue(func.info.desc)
Ejemplo n.º 12
0
    def test_glib_shadowed(self):
        repo = Repository("GLib", "2.0")

        # GLib.io_add_watch points to g_io_add_watch_full and should
        # also use its docs

        self.assertTrue(
            repo.lookup_parameter_docs("GLib.io_add_watch.priority"))

        self.assertTrue(
            "priority" in repo.lookup_attr_docs("GLib.io_add_watch"))

        # we include a note containing the shadowed docs
        self.assertTrue(
            ".. note::" in repo.lookup_attr_docs("GLib.io_add_watch"))
Ejemplo n.º 13
0
    def test_gobject(self):
        repo = Repository("GObject", "2.0")
        mod = repo.parse()

        self.assertEqual(
            repo.lookup_py_id_for_type_struct("GObjectClass"),
            "GObject.Object")

        klass = find(mod.enums, "GEnum")
        self.assertEqual(klass.base, "GLib.Enum")

        klass = find(mod.flags, "GFlags")
        self.assertEqual(klass.base, "GLib.Flags")

        klass = find(mod.flags, "ParamFlags")
        self.assertEqual(klass.base, "GLib.Flags")
Ejemplo n.º 14
0
    def test_gio(self):
        repo = Repository("Gio", "2.0")

        method = repo.lookup_attr_docs("Gio.Application.activate")
        signal = repo.lookup_signal_docs("Gio.Application.activate")

        self.assertTrue(method)
        self.assertTrue(signal)
        self.assertNotEqual(method, signal)

        self.assertFalse(
            repo.lookup_parameter_docs(
                "Gio.Application.command-line.command_line"))

        self.assertTrue(
            repo.lookup_parameter_docs(
                "Gio.Application.command-line.command_line", signal=True))
Ejemplo n.º 15
0
    def test_atk(self):
        repo = Repository("Atk", "1.0")
        Atk = repo.import_module()

        klass = Class.from_object(repo, Atk.Document)
        method = find(klass.methods, "get_attributes")
        self.assertEqual(method.info.version_added, "1.12")

        method = find(klass.methods, "get_attribute_value")
        self.assertEqual(method.info.version_added, "1.12")

        klass = Class.from_object(repo, Atk.Hyperlink)

        method = find(klass.methods, "is_selected_link")
        self.assertTrue(method.info.deprecated)
        self.assertEqual(method.info.version_added, "1.4")
        self.assertEqual(method.info.version_deprecated, "1.8")
        self.assertTrue(method.info.deprecation_desc, "1.8")
Ejemplo n.º 16
0
    def test_gio(self):
        repo = Repository("Gio", "2.0")
        Gio = repo.import_module()

        klass = Class.from_object(repo, Gio.Application)
        method = find(klass.methods, "activate")
        signal = find(klass.signals, "activate")

        self.assertTrue(method.info.desc)
        self.assertTrue(signal.info.desc)
        self.assertNotEqual(method.info.desc, signal.info.desc)

        signal = find(klass.signals, "command_line")
        self.assertTrue(":param command_line:" in signal.signature_desc)

        klass = Class.from_object(repo, Gio.File)
        method = find(klass.methods, "load_contents_finish")
        self.assertTrue(":returns:" in method.signature_desc)
Ejemplo n.º 17
0
    def test_gtk(self):
        repo = Repository("Gtk", "3.0")
        mod = repo.parse()
        Gtk = repo.import_module()

        klass = Class.from_object(repo, Gtk.TreeModel)
        vfunc = find(klass.vfuncs, "do_get_iter")
        self.assertTrue(vfunc.info.desc)

        Class.from_object(repo, Gtk.Button)
        Class.from_object(repo, Gtk.Paned)
        Class.from_object(repo, Gtk.ActionBar)

        klass = Class.from_object(repo, Gtk.TextView)
        self.assertTrue(klass.image_path)

        find(mod.class_structures, "WidgetClass")
        find(mod.structures, "TableChild")
        self.assertRaises(LookupError, find, mod.class_structures, "TableChild")
        self.assertRaises(LookupError, find, mod.structures, "WidgetClass")
Ejemplo n.º 18
0
    def test_gobject(self):
        repo = Repository("GObject", "2.0")
        GObject = repo.import_module()
        mod = repo.parse()

        self.assertEqual(
            repo.lookup_py_id_for_type_struct("GObjectClass"),
            "GObject.Object")

        klass = Class.from_object(repo, GObject.Object)
        method = find(klass.methods, "list_properties")
        self.assertTrue(method.is_static)
        self.assertEqual(method.fullname, "GObject.Object.list_properties")

        klass = find(mod.enums, "GEnum")
        self.assertEqual(klass.base, "GLib.Enum")

        klass = find(mod.flags, "GFlags")
        self.assertEqual(klass.base, "GLib.Flags")

        klass = find(mod.flags, "ParamFlags")
        self.assertEqual(klass.base, "GLib.Flags")
Ejemplo n.º 19
0
    def test_pango(self):
        repo = Repository("Pango", "1.0")

        self.assertTrue(
            repo.lookup_parameter_docs("Pango.extents_to_pixels.inclusive"))

        self.assertTrue(
            repo.lookup_parameter_docs("Pango.break_.text"))

        self.assertTrue(
            repo.lookup_parameter_docs("Pango.TabArray.new.initial_size"))

        self.assertTrue(repo.is_private("Pango.RendererPrivate"))
        self.assertFalse(repo.is_private("Pango.AttrIterator"))
Ejemplo n.º 20
0
 def test_method_inheritance(self):
     repo = Repository("Atk", "1.0")
     Atk = repo.import_module()
     klass = Class.from_object(repo, Atk.Plug)
     self.assertEqual([x[0] for x in klass.methods_inherited],
                      ['Atk.Object', 'GObject.Object', 'Atk.Component'])
Ejemplo n.º 21
0
 def test_override_method(self):
     repo = Repository("Gtk", "3.0")
     Gtk = repo.import_module()
     func = Function.from_object(
         "Gtk.Widget", "translate_coordinates", Gtk.Widget.translate_coordinates, repo, Gtk.Widget)
     self.assertEqual(func.signature, "(dest_widget, src_x, src_y)")
Ejemplo n.º 22
0
 def test_gudev(self):
     repo = Repository("GUdev", "1.0")
     GUdev = repo.import_module()
     Class.from_object(repo, GUdev.Client)
Ejemplo n.º 23
0
 def test_gobject(self):
     Repository("GObject", "2.0")
Ejemplo n.º 24
0
 def test_gudev(self):
     repo = Repository("GUdev", "1.0")
     GUdev = repo.import_module()
     Class.from_object(repo, GUdev.Client)
Ejemplo n.º 25
0
    def test_webkit2(self):
        from gi.repository import WebKit2

        repo = Repository("Atk", "1.0")
        # contains signal named "print", which needs special handling
        repo.parse_signals(WebKit2.WebView)
Ejemplo n.º 26
0
 def test_deprecated(self):
     repo = Repository("Atk", "1.0")
     docs = repo.lookup_attr_meta("Atk.Hyperlink.is_selected_link")
     self.assertTrue(".. deprecated::" in docs)
Ejemplo n.º 27
0
    def test_props(self):
        from pgi.repository import Gtk

        repo = Repository("Gtk", "3.0")
        self.assertTrue(repo.parse_properties(Gtk.Button))
        self.assertTrue(repo.parse_signals(Gtk.Button))
Ejemplo n.º 28
0
    def test_vfuns(self):
        repo = Repository("Gtk", "3.0")

        ret = repo.lookup_attr_docs("Gtk.TreeModel.do_get_iter")
        self.assertTrue(ret.strip())
Ejemplo n.º 29
0
    def test_returns(self):
        repo = Repository("Gio", "2.0")

        ret = repo.lookup_return_docs("Gio.File.load_contents_finish")
        self.assertTrue(ret.strip())
Ejemplo n.º 30
0
    def test_child_props(self):
        from pgi.repository import Gtk

        repo = Repository("Gtk", "3.0")
        repo.parse_child_properties(Gtk.Paned)
        repo.parse_child_properties(Gtk.ActionBar)