bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
1616.1.13
by Martin Pool
 Fix 'bzr -h' to show help (#35940)  | 
1  | 
# Copyright (C) 2005, 2006 Canonical Ltd
 | 
| 
1185.16.48
by mbp at sourcefrog
 - more refactoring of and tests for option parsing  | 
2  | 
|
| 
1185.31.25
by John Arbash Meinel
 Renamed all of the tests from selftest/foo.py to tests/test_foo.py  | 
3  | 
from bzrlib.tests import TestCase  | 
| 
1185.16.48
by mbp at sourcefrog
 - more refactoring of and tests for option parsing  | 
4  | 
from bzrlib.commands import Command, parse_args  | 
5  | 
from bzrlib.builtins import cmd_commit, cmd_log, cmd_status  | 
|
6  | 
||
| 
1616.1.13
by Martin Pool
 Fix 'bzr -h' to show help (#35940)  | 
7  | 
# TODO: might be nice to just parse them into a structured form and test
 | 
8  | 
# against that, rather than running the whole command.
 | 
|
| 
1185.16.48
by mbp at sourcefrog
 - more refactoring of and tests for option parsing  | 
9  | 
|
10  | 
class OptionTests(TestCase):  | 
|
11  | 
"""Command-line option tests"""  | 
|
12  | 
||
13  | 
def test_parse_args(self):  | 
|
14  | 
"""Option parser"""  | 
|
15  | 
eq = self.assertEquals  | 
|
16  | 
eq(parse_args(cmd_commit(), ['--help']),  | 
|
17  | 
([], {'help': True}))  | 
|
18  | 
eq(parse_args(cmd_status(), ['--all']),  | 
|
19  | 
([], {'all': True}))  | 
|
20  | 
eq(parse_args(cmd_commit(), ['--message=biter']),  | 
|
21  | 
([], {'message': 'biter'}))  | 
|
22  | 
        ## eq(parse_args(cmd_log(),  '-r 500'.split()),
 | 
|
23  | 
        ##   ([], {'revision': RevisionSpec_int(500)}))
 | 
|
24  | 
||
| 
1185.16.49
by mbp at sourcefrog
 - more refactoring and tests of commandline  | 
25  | 
def test_no_more_opts(self):  | 
26  | 
"""Terminated options"""  | 
|
27  | 
self.assertEquals(parse_args(cmd_commit(), ['--', '-file-with-dashes']),  | 
|
28  | 
(['-file-with-dashes'], {}))  | 
|
29  | 
||
| 
1185.16.48
by mbp at sourcefrog
 - more refactoring of and tests for option parsing  | 
30  | 
def test_option_help(self):  | 
31  | 
"""Options have help strings."""  | 
|
32  | 
out, err = self.run_bzr_captured(['commit', '--help'])  | 
|
33  | 
self.assertContainsRe(out, r'--file.*file containing commit message')  | 
|
| 
1185.25.3
by Aaron Bentley
 Restored short options in help  | 
34  | 
self.assertContainsRe(out, r'--help.*-h')  | 
| 
1185.16.48
by mbp at sourcefrog
 - more refactoring of and tests for option parsing  | 
35  | 
|
36  | 
def test_option_help_global(self):  | 
|
37  | 
"""Global options have help strings."""  | 
|
38  | 
out, err = self.run_bzr_captured(['help', 'status'])  | 
|
39  | 
self.assertContainsRe(out, r'--show-ids.*show internal object')  | 
|
40  | 
||
41  | 
def test_option_arg_help(self):  | 
|
42  | 
"""Help message shows option arguments."""  | 
|
43  | 
out, err = self.run_bzr_captured(['help', 'commit'])  | 
|
44  | 
self.assertEquals(err, '')  | 
|
45  | 
self.assertContainsRe(out, r'--file[ =]MSGFILE')  | 
|
46  | 
||
| 
1185.35.24
by Aaron Bentley
 Fixed handling of short options not accepted by the command  | 
47  | 
def test_unknown_short_opt(self):  | 
48  | 
out, err = self.run_bzr_captured(['help', '-r'], retcode=3)  | 
|
49  | 
self.assertContainsRe(err, r'unknown short option')  | 
|
50  | 
||
| 
1185.16.48
by mbp at sourcefrog
 - more refactoring of and tests for option parsing  | 
51  | 
|
52  | 
#     >>> parse_args('log -r 500'.split())
 | 
|
53  | 
#     (['log'], {'revision': [<RevisionSpec_int 500>]})
 | 
|
54  | 
#     >>> parse_args('log -r500..600'.split())
 | 
|
55  | 
#     (['log'], {'revision': [<RevisionSpec_int 500>, <RevisionSpec_int 600>]})
 | 
|
56  | 
#     >>> parse_args('log -vr500..600'.split())
 | 
|
57  | 
#     (['log'], {'verbose': True, 'revision': [<RevisionSpec_int 500>, <RevisionSpec_int 600>]})
 | 
|
58  | 
#     >>> parse_args('log -rrevno:500..600'.split()) #the r takes an argument
 | 
|
59  | 
#     (['log'], {'revision': [<RevisionSpec_revno revno:500>, <RevisionSpec_int 600>]})
 |