summaryrefslogtreecommitdiff
path: root/tests/test_option.py
diff options
context:
space:
mode:
authorJohannes Hölzl <johannes.hoelzl@gmx.de>2006-04-29 18:58:20 +0000
committerJohan Dahlin <johan@src.gnome.org>2006-04-29 18:58:20 +0000
commit6896d50402332dcac8d079d48d22e30c3e0f7231 (patch)
tree626e46020f2134d9254a7f190ff7fba59310cad3 /tests/test_option.py
parentcd01d8f09504748a17e1e7ae68ada9d4edaf23fe (diff)
downloadpygobject-6896d50402332dcac8d079d48d22e30c3e0f7231.tar.gz
reviewed by: Johan Dahlin <jdahlin@async.com.br>
2006-04-29 Johannes Hölzl <johannes.hoelzl@gmx.de> reviewed by: Johan Dahlin <jdahlin@async.com.br> * examples/Makefile.am: * examples/option.py: * gobject/Makefile.am: * gobject/gobjectmodule.c: (init_gobject): * gobject/option.py: * gobject/pygobject-private.h: * gobject/pygoptioncontext.c: (pyg_option_context_init), (pyg_option_context_dealloc), (pyg_option_context_parse), (pyg_option_context_set_help_enabled), (pyg_option_context_get_help_enabled), (pyg_option_context_set_ignore_unknown_options), (pyg_option_context_get_ignore_unknown_options), (pyg_option_context_set_main_group), (pyg_option_context_get_main_group), (pyg_option_context_add_group), (pyg_option_context_compare), (pyg_option_context_new): * gobject/pygoptiongroup.c: (check_if_owned), (destroy_g_group), (pyg_option_group_init), (pyg_option_group_dealloc), (arg_func), (pyg_option_group_add_entries), (pyg_option_group_set_translation_domain), (pyg_option_group_compare), (pyg_option_group_transfer_group), (pyg_option_group_new): * tests/test_option.py: Add support for GOption, fixes #163645
Diffstat (limited to 'tests/test_option.py')
-rw-r--r--tests/test_option.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test_option.py b/tests/test_option.py
new file mode 100644
index 00000000..ace7bdbd
--- /dev/null
+++ b/tests/test_option.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+
+import unittest
+
+from common import gobject
+from gobject import option
+
+class TestOption(unittest.TestCase):
+
+ def setup_group(self):
+ group = option.OptionGroup(
+ "unittest", "Unit test options", "Show all unittest options",
+ option_list = [
+ option.make_option("-f", "-u", "--file", "--unit-file",
+ type="filename",
+ dest="unit_file",
+ help="Unit test option"),
+ ])
+ group.add_option("-t", "--test",
+ action="store_false",
+ dest="test",
+ default=True,
+ help="Unit test option")
+ return group
+
+ def setup_parser(self):
+ parser = option.OptionParser("NAMES...", description="Option unit test")
+ parser.add_option("-t", "--test", help="Unit test option",
+ action="store_false", dest="test", default=True)
+ return parser
+
+ def testOption(self):
+ parser = self.setup_parser()
+ group = self.setup_group()
+ parser.add_option_group(group)
+
+ parser.parse_args(["test_option.py", "--test", "-f", "test"])
+ assert group.values.test
+ assert not parser.values.test
+ assert group.values.unit_file == "test"