summaryrefslogtreecommitdiff
path: root/tests/test_option.py
diff options
context:
space:
mode:
authorMartin Pitt <martinpitt@gnome.org>2012-10-24 15:16:13 +0200
committerMartin Pitt <martinpitt@gnome.org>2012-10-24 15:16:13 +0200
commite6e047ef9b8575c852b3cdc3f5d4dfbb548cc648 (patch)
tree4fed1d1b1e483856dec2453a309ccc04fe4c4093 /tests/test_option.py
parent6a586af41b8740c4ba590591d1068d80071ff2dc (diff)
downloadpygobject-e6e047ef9b8575c852b3cdc3f5d4dfbb548cc648.tar.gz
test_option: Use public API
Use GLib.option, not gi._glib.option.
Diffstat (limited to 'tests/test_option.py')
-rw-r--r--tests/test_option.py42
1 files changed, 20 insertions, 22 deletions
diff --git a/tests/test_option.py b/tests/test_option.py
index 88a571ff..2900edd2 100644
--- a/tests/test_option.py
+++ b/tests/test_option.py
@@ -10,17 +10,15 @@ try:
except ImportError:
from io import StringIO
-# FIXME: we need a way to import the options module from a public module
-from gi._glib.option import OptionParser, OptionGroup, OptionValueError, \
- make_option, BadOptionError
+from gi.repository import GLib
class TestOption(unittest.TestCase):
EXCEPTION_MESSAGE = "This callback fails"
def setUp(self):
- self.parser = OptionParser("NAMES...",
- description="Option unit test")
+ self.parser = GLib.option.OptionParser("NAMES...",
+ description="Option unit test")
self.parser.add_option("-t", "--test", help="Unit test option",
action="store_false", dest="test", default=True)
self.parser.add_option("--g-fatal-warnings",
@@ -32,22 +30,22 @@ class TestOption(unittest.TestCase):
def option_callback(option, opt, value, parser):
raise Exception(self.EXCEPTION_MESSAGE)
- group = OptionGroup(
+ group = GLib.option.OptionGroup(
"unittest", "Unit test options", "Show all unittest options",
option_list=[
- make_option("-f", "-u", "--file", "--unit-file",
- type="filename",
- dest="unit_file",
- help="Unit test option"),
- make_option("--test-integer",
- type="int",
- dest="test_integer",
- help="Unit integer option"),
- make_option("--callback-failure-test",
- action="callback",
- callback=option_callback,
- dest="test_integer",
- help="Unit integer option"),
+ GLib.option.make_option("-f", "-u", "--file", "--unit-file",
+ type="filename",
+ dest="unit_file",
+ help="Unit test option"),
+ GLib.option.make_option("--test-integer",
+ type="int",
+ dest="test_integer",
+ help="Unit integer option"),
+ GLib.option.make_option("--callback-failure-test",
+ action="callback",
+ callback=option_callback,
+ dest="test_integer",
+ help="Unit integer option"),
])
group.add_option("-t", "--test",
action="store_false",
@@ -91,16 +89,16 @@ class TestOption(unittest.TestCase):
def test_option_value_error(self):
self._create_group()
- self.assertRaises(OptionValueError, self.parser.parse_args,
+ self.assertRaises(GLib.option.OptionValueError, self.parser.parse_args,
["test_option.py", "--test-integer=text"])
def test_bad_option_error(self):
- self.assertRaises(BadOptionError,
+ self.assertRaises(GLib.option.BadOptionError,
self.parser.parse_args,
["test_option.py", "--unknwon-option"])
def test_option_group_constructor(self):
- self.assertRaises(TypeError, OptionGroup)
+ self.assertRaises(TypeError, GLib.option.OptionGroup)
def test_standard_error(self):
self._create_group()