summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_optparse.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_optparse.py')
-rw-r--r--Lib/test/test_optparse.py64
1 files changed, 32 insertions, 32 deletions
diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py
index 9c52f86..cdbbc9d 100644
--- a/Lib/test/test_optparse.py
+++ b/Lib/test/test_optparse.py
@@ -109,7 +109,7 @@ Args were %(args)s.""" % locals ())
except expected_exception as err:
actual_message = str(err)
if isinstance(expected_message, retype):
- self.assert_(expected_message.search(actual_message),
+ self.assertTrue(expected_message.search(actual_message),
"""\
expected exception message pattern:
/%s/
@@ -165,7 +165,7 @@ and kwargs %(kwargs)r
sys.stdout = save_stdout
except InterceptedError as err:
- self.assert_(
+ self.assertTrue(
isinstance(output, str),
"expected output to be an ordinary string, not %r"
% type(output))
@@ -338,7 +338,7 @@ class TestOptionParser(BaseTest):
def test_get_option(self):
opt1 = self.parser.get_option("-v")
- self.assert_(isinstance(opt1, Option))
+ self.assertTrue(isinstance(opt1, Option))
self.assertEqual(opt1._short_opts, ["-v", "-n"])
self.assertEqual(opt1._long_opts, ["--verbose", "--noisy"])
self.assertEqual(opt1.action, "store_true")
@@ -349,33 +349,33 @@ class TestOptionParser(BaseTest):
opt2 = self.parser.get_option("--verbose")
opt3 = self.parser.get_option("-n")
opt4 = self.parser.get_option("--noisy")
- self.assert_(opt1 is opt2 is opt3 is opt4)
+ self.assertTrue(opt1 is opt2 is opt3 is opt4)
def test_has_option(self):
- self.assert_(self.parser.has_option("-v"))
- self.assert_(self.parser.has_option("--verbose"))
+ self.assertTrue(self.parser.has_option("-v"))
+ self.assertTrue(self.parser.has_option("--verbose"))
- def assert_removed(self):
- self.assert_(self.parser.get_option("-v") is None)
- self.assert_(self.parser.get_option("--verbose") is None)
- self.assert_(self.parser.get_option("-n") is None)
- self.assert_(self.parser.get_option("--noisy") is None)
+ def assertTrueremoved(self):
+ self.assertTrue(self.parser.get_option("-v") is None)
+ self.assertTrue(self.parser.get_option("--verbose") is None)
+ self.assertTrue(self.parser.get_option("-n") is None)
+ self.assertTrue(self.parser.get_option("--noisy") is None)
- self.failIf(self.parser.has_option("-v"))
- self.failIf(self.parser.has_option("--verbose"))
- self.failIf(self.parser.has_option("-n"))
- self.failIf(self.parser.has_option("--noisy"))
+ self.assertFalse(self.parser.has_option("-v"))
+ self.assertFalse(self.parser.has_option("--verbose"))
+ self.assertFalse(self.parser.has_option("-n"))
+ self.assertFalse(self.parser.has_option("--noisy"))
- self.assert_(self.parser.has_option("-q"))
- self.assert_(self.parser.has_option("--silent"))
+ self.assertTrue(self.parser.has_option("-q"))
+ self.assertTrue(self.parser.has_option("--silent"))
def test_remove_short_opt(self):
self.parser.remove_option("-n")
- self.assert_removed()
+ self.assertTrueremoved()
def test_remove_long_opt(self):
self.parser.remove_option("--verbose")
- self.assert_removed()
+ self.assertTrueremoved()
def test_remove_nonexistent(self):
self.assertRaises(self.parser.remove_option, ('foo',), None,
@@ -779,14 +779,14 @@ class TestBool(BaseTest):
{'verbose': 0},
[])
if hasattr(__builtins__, 'False'):
- self.failUnless(options.verbose is False)
+ self.assertTrue(options.verbose is False)
def test_bool_true(self):
(options, args) = self.assertParseOK(["-v"],
{'verbose': 1},
[])
if hasattr(__builtins__, 'True'):
- self.failUnless(options.verbose is True)
+ self.assertTrue(options.verbose is True)
def test_bool_flicker_on_and_off(self):
self.assertParseOK(["-qvq", "-q", "-v"],
@@ -992,7 +992,7 @@ class TestOptionGroup(BaseTest):
description="Some more options")
group.set_title("Bacon")
group.add_option("--bacon", type="int")
- self.assert_(self.parser.get_option_group("--bacon"), group)
+ self.assertTrue(self.parser.get_option_group("--bacon"), group)
# -- Test extending and parser.parse_args() ----------------------------
@@ -1088,15 +1088,15 @@ class TestCallback(BaseTest):
if opt == "-x":
self.assertEqual(option._short_opts, ["-x"])
self.assertEqual(option._long_opts, [])
- self.assert_(parser_ is self.parser)
- self.assert_(value is None)
+ self.assertTrue(parser_ is self.parser)
+ self.assertTrue(value is None)
self.assertEqual(vars(parser_.values), {'filename': None})
parser_.values.x = 42
elif opt == "--file":
self.assertEqual(option._short_opts, ["-f"])
self.assertEqual(option._long_opts, ["--file"])
- self.assert_(parser_ is self.parser)
+ self.assertTrue(parser_ is self.parser)
self.assertEqual(value, "foo")
self.assertEqual(vars(parser_.values), {'filename': None, 'x': 42})
@@ -1134,7 +1134,7 @@ class TestCallbackExtraArgs(BaseTest):
def process_tuple(self, option, opt, value, parser_, len, type):
self.assertEqual(len, 3)
- self.assert_(type is int)
+ self.assertTrue(type is int)
if opt == "-p":
self.assertEqual(value, "1,2,3")
@@ -1225,7 +1225,7 @@ class TestCallbackVarArgs(BaseTest):
option_list=options)
def variable_args(self, option, opt, value, parser):
- self.assert_(value is None)
+ self.assertTrue(value is None)
done = 0
value = []
rargs = parser.rargs
@@ -1281,7 +1281,7 @@ class ConflictBase(BaseTest):
class TestConflict(ConflictBase):
"""Use the default conflict resolution for Optik 1.2: error."""
- def assert_conflict_error(self, func):
+ def assertTrueconflict_error(self, func):
err = self.assertRaises(
func, ("-v", "--version"), {'action' : "callback",
'callback' : self.show_version,
@@ -1293,11 +1293,11 @@ class TestConflict(ConflictBase):
self.assertEqual(err.option_id, "-v/--version")
def test_conflict_error(self):
- self.assert_conflict_error(self.parser.add_option)
+ self.assertTrueconflict_error(self.parser.add_option)
def test_conflict_error_group(self):
group = OptionGroup(self.parser, "Group 1")
- self.assert_conflict_error(group.add_option)
+ self.assertTrueconflict_error(group.add_option)
def test_no_such_conflict_handler(self):
self.assertRaises(
@@ -1317,8 +1317,8 @@ class TestConflictResolve(ConflictBase):
verbose_opt = self.parser.get_option("--verbose")
version_opt = self.parser.get_option("--version")
- self.assert_(v_opt is version_opt)
- self.assert_(v_opt is not verbose_opt)
+ self.assertTrue(v_opt is version_opt)
+ self.assertTrue(v_opt is not verbose_opt)
self.assertEqual(v_opt._long_opts, ["--version"])
self.assertEqual(version_opt._short_opts, ["-v"])
self.assertEqual(version_opt._long_opts, ["--version"])