19
19
from bzrlib import (
28
from bzrlib.builtins import cmd_commit, cmd_log, cmd_status
25
from bzrlib.builtins import cmd_commit
29
26
from bzrlib.commands import Command, parse_args
30
27
from bzrlib.tests import TestCase
31
28
from bzrlib.repofmt import knitrepo
42
39
def test_parse_args(self):
43
40
"""Option parser"""
44
eq = self.assertEquals
45
eq(parse_args(cmd_commit(), ['--help']),
46
([], {'fixes': [], 'help': True}))
47
eq(parse_args(cmd_commit(), ['--message=biter']),
48
([], {'fixes': [], 'message': 'biter'}))
41
# XXX: Using cmd_commit makes these tests overly sensitive to changes
42
# to cmd_commit, when they are meant to be about option parsing in
44
self.assertEqual(parse_args(cmd_commit(), ['--help']),
45
([], {'exclude': [], 'fixes': [], 'help': True}))
46
self.assertEqual(parse_args(cmd_commit(), ['--message=biter']),
47
([], {'exclude': [], 'fixes': [], 'message': 'biter'}))
50
49
def test_no_more_opts(self):
51
50
"""Terminated options"""
52
self.assertEquals(parse_args(cmd_commit(), ['--', '-file-with-dashes']),
53
(['-file-with-dashes'], {'fixes': []}))
51
self.assertEqual(parse_args(cmd_commit(), ['--', '-file-with-dashes']),
52
(['-file-with-dashes'], {'exclude': [], 'fixes': []}))
55
54
def test_option_help(self):
56
55
"""Options have help strings."""
67
66
def test_option_arg_help(self):
68
67
"""Help message shows option arguments."""
69
68
out, err = self.run_bzr('help commit')
70
self.assertEquals(err, '')
69
self.assertEqual(err, '')
71
70
self.assertContainsRe(out, r'--file[ =]MSGFILE')
73
72
def test_unknown_short_opt(self):
82
81
def test_allow_dash(self):
83
82
"""Test that we can pass a plain '-' as an argument."""
85
(['-'], {'fixes': []}), parse_args(cmd_commit(), ['-']))
83
self.assertEqual((['-']), parse_args(cmd_commit(), ['-'])[0])
87
85
def parse(self, options, args):
88
86
parser = option.get_optparser(dict((o.name, o) for o in options))