~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_options.py

  • Committer: Andrew Bennetts
  • Date: 2008-08-07 00:25:38 UTC
  • mfrom: (3612 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3613.
  • Revision ID: andrew.bennetts@canonical.com-20080807002538-mtl1fcgy2fdabha4
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import re
18
18
 
19
19
from bzrlib import (
20
 
    builtins,
21
20
    bzrdir,
22
21
    commands,
23
22
    errors,
24
23
    option,
25
 
    repository,
26
 
    symbol_versioning,
27
24
    )
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
41
38
 
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
 
43
        # general.
 
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'}))
49
48
 
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': []}))
54
53
 
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')
72
71
 
73
72
    def test_unknown_short_opt(self):
81
80
 
82
81
    def test_allow_dash(self):
83
82
        """Test that we can pass a plain '-' as an argument."""
84
 
        self.assertEqual(
85
 
            (['-'], {'fixes': []}), parse_args(cmd_commit(), ['-']))
 
83
        self.assertEqual((['-']), parse_args(cmd_commit(), ['-'])[0])
86
84
 
87
85
    def parse(self, options, args):
88
86
        parser = option.get_optparser(dict((o.name, o) for o in options))