1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# (C) 2005 Canonical
from bzrlib.selftest import TestCase
from bzrlib.commands import Command, parse_args
from bzrlib.builtins import cmd_commit, cmd_log, cmd_status
class OptionTests(TestCase):
"""Command-line option tests"""
def test_parse_args(self):
"""Option parser"""
eq = self.assertEquals
eq(parse_args(cmd_commit(), ['--help']),
([], {'help': True}))
eq(parse_args(cmd_status(), ['--all']),
([], {'all': True}))
eq(parse_args(cmd_commit(), ['--message=biter']),
([], {'message': 'biter'}))
## eq(parse_args(cmd_log(), '-r 500'.split()),
## ([], {'revision': RevisionSpec_int(500)}))
def test_no_more_opts(self):
"""Terminated options"""
self.assertEquals(parse_args(cmd_commit(), ['--', '-file-with-dashes']),
(['-file-with-dashes'], {}))
def test_option_help(self):
"""Options have help strings."""
out, err = self.run_bzr_captured(['commit', '--help'])
self.assertContainsRe(out, r'--file.*file containing commit message')
self.assertContainsRe(out, r'--help.*-h')
def test_option_help_global(self):
"""Global options have help strings."""
out, err = self.run_bzr_captured(['help', 'status'])
self.assertContainsRe(out, r'--show-ids.*show internal object')
def test_option_arg_help(self):
"""Help message shows option arguments."""
out, err = self.run_bzr_captured(['help', 'commit'])
self.assertEquals(err, '')
self.assertContainsRe(out, r'--file[ =]MSGFILE')
# >>> parse_args('log -r 500'.split())
# (['log'], {'revision': [<RevisionSpec_int 500>]})
# >>> parse_args('log -r500..600'.split())
# (['log'], {'revision': [<RevisionSpec_int 500>, <RevisionSpec_int 600>]})
# >>> parse_args('log -vr500..600'.split())
# (['log'], {'verbose': True, 'revision': [<RevisionSpec_int 500>, <RevisionSpec_int 600>]})
# >>> parse_args('log -rrevno:500..600'.split()) #the r takes an argument
# (['log'], {'revision': [<RevisionSpec_revno revno:500>, <RevisionSpec_int 600>]})
|