~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testoptions.py

  • Committer: Robert Collins
  • Date: 2005-10-17 21:20:18 UTC
  • mfrom: (1461)
  • mto: This revision was merged to the branch mainline in revision 1462.
  • Revision ID: robertc@robertcollins.net-20051017212018-5e2a78c67f36a026
merge from integration

Show diffs side-by-side

added added

removed removed

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