File: test_tree_string_representation_gtk3.py

package info (click to toggle)
dogtail 2.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 1,108 kB
  • sloc: python: 8,020; makefile: 45; sh: 7
file content (63 lines) | stat: -rw-r--r-- 1,626 bytes parent folder | download
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
#!/usr/bin/python3
"""
Unit tests for the dogtail.tree Node String Representation.
"""

# pylint: disable=import-outside-toplevel
# pylint: disable=wrong-import-position
# pylint: disable=wrong-import-order
# ruff: noqa: E402


import os
import unittest

try:
    from tests.test_gtk_demo import Gtk3DemoTest, trap_stdout
except ImportError:
    from test_gtk_demo import Gtk3DemoTest, trap_stdout


SOURCE_DUMP_STRING = """[ 'Source' | 'page tab' | '' ]
  [ '' | 'scroll pane' | '' ]
    [ '' | 'text' | '' ]
    [ '' | 'scroll bar' | '' ]
    [ '' | 'scroll bar' | '' ]"""

SOURCE_TREE_STRING = """└──[ 'Source' | 'page tab' | '' ]
     └──[ '' | 'scroll pane' | '' ]
         ├──[ '' | 'text' | '' ]
         ├──[ '' | 'scroll bar' | '' ]
         └──[ '' | 'scroll bar' | '' ]"""


@unittest.skipIf(not os.path.isfile("/usr/bin/gtk3-demo"), "Skipping, no gtk3-demo.")
class TestGtk3DogtailNodeValue(Gtk3DemoTest):
    """
    Class to test dogtail's Node String Representation.
    """

    def test_dump_representation(self):
        """
        Testing dump string.
        """

        source_node = self.demo.child("Source")

        source_node_dump_output = trap_stdout(source_node.dump)
        self.assertEqual(source_node_dump_output, SOURCE_DUMP_STRING)


    def test_tree_representation(self):
        """
        Testing tree string.
        """

        source_node = self.demo.child("Source")

        source_node_tree_output = trap_stdout(source_node.tree)
        self.assertEqual(source_node_tree_output, SOURCE_TREE_STRING)


if __name__ == "__main__":
    unittest.main()