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()
|