pidgin/tests/test-wrapper.py

Tue, 31 Oct 2023 01:12:44 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 31 Oct 2023 01:12:44 -0500
changeset 42456
73bb1fae628c
child 42479
d0faa9b1ac85
permissions
-rwxr-xr-x

Create pidgin_text_buffer API for working with GtkTextBuffers

Currently we only implement _get_html and _get_html_range and only a subset of
html tags are identified properly. This was intentional as it's easy to add
additional tags and because we're also introducing testing to Pidgin in this
commit.

Testing Done:
Ran the unit tests under valgrind without issues.

Reviewed at https://reviews.imfreedom.org/r/2754/

42456
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 #!/usr/bin/env python3
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 #
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 # Pidgin - Internet Messenger
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 # Copyright (C) Pidgin Developers <devel@pidgin.im>
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 #
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 # Pidgin is the legal property of its developers, whose names are too numerous
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 # to list here. Please refer to the COPYRIGHT file distributed with this
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 # source distribution.
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 #
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 # This program is free software; you can redistribute it and/or modify
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 # it under the terms of the GNU General Public License as published by
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 # the Free Software Foundation; either version 2 of the License, or
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 # (at your option) any later version.
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 #
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 # This program is distributed in the hope that it will be useful,
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 # GNU General Public License for more details.
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 # You should have received a copy of the GNU General Public License
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 # along with this library; if not, see <https://www.gnu.org/licenses/>.
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 """
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 This script will run the command specified via command line arguments,
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 making sure broadwayd is running and will be used.
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 """
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 import os
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 import subprocess
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 import sys
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 def main():
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 # start broadway
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 broadwayd = subprocess.Popen(['gtk4-broadwayd'])
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 # run the unit test but set the GDK_BACKEND envvar to broadway
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 env = {**os.environ, 'GDK_BACKEND': 'broadway'}
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 try:
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 proc = subprocess.run(args=sys.argv[1:], env=env)
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 finally:
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 # kill broadway
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 broadwayd.kill()
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 # return the exit code of the unit test
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 sys.exit(proc.returncode)
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 if __name__ == '__main__':
73bb1fae628c Create pidgin_text_buffer API for working with GtkTextBuffers
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 main()

mercurial