File: gobject-query.py

package info (click to toggle)
glib2.0 2.86.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 67,020 kB
  • sloc: ansic: 544,698; python: 9,702; sh: 1,612; xml: 1,482; perl: 1,222; cpp: 535; makefile: 308; javascript: 11
file content (71 lines) | stat: -rw-r--r-- 2,365 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright © 2022 Endless OS Foundation, LLC
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA  02110-1301  USA

"""Integration tests for gobject-query utility."""

import unittest

import taptestrunner
import testprogramrunner


class TestGobjectQuery(testprogramrunner.TestProgramRunner):
    """Integration test for running gobject-query.

    This can be run when installed or uninstalled. When uninstalled, it
    requires G_TEST_BUILDDIR and G_TEST_SRCDIR to be set.

    The idea with this test harness is to test the gobject-query utility, its
    handling of command line arguments, and its exit statuses.
    """

    PROGRAM_NAME = "gobject-query"

    def runGobjectQuery(self, *args):
        return self.runTestProgram(args)

    def test_help(self):
        """Test the --help argument."""
        result = self.runGobjectQuery("--help")
        self.assertIn("usage: gobject-query", result.out)

    def test_version(self):
        """Test the --version argument."""
        result = self.runGobjectQuery("--version")
        self.assertIn("2.", result.out)

    def test_froots(self):
        """Test running froots with no other arguments."""
        result = self.runGobjectQuery("froots")

        self.assertEqual("", result.err)
        self.assertIn("├gboolean", result.out)
        self.assertIn("├GObject", result.out)

    def test_tree(self):
        """Test running tree with no other arguments."""
        result = self.runGobjectQuery("tree")

        self.assertEqual("", result.err)
        self.assertIn("GObject", result.out)


if __name__ == "__main__":
    unittest.main(testRunner=taptestrunner.TAPTestRunner())