1
# Copyright (C) 2005, 2006 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
17
17
from bzrlib.builtins import cmd_commit, cmd_log, cmd_status
18
18
from bzrlib.commands import Command, parse_args
19
from bzrlib import errors
20
from bzrlib import option
21
24
from bzrlib.tests import TestCase
23
26
# TODO: might be nice to just parse them into a structured form and test
69
72
force_opt = option.Option.OPTIONS['force']
70
73
self.assertEquals(force_opt.short_name(), None)
75
def test_old_short_names(self):
76
# test the deprecated method for getting and setting short option
79
"access to SHORT_OPTIONS was deprecated in version 0.14."
80
" Set the short option name when constructing the Option.",
81
DeprecationWarning, 2)
83
def capture_warning(message, category, stacklevel=None):
84
_warnings.append((message, category, stacklevel))
85
old_warning_method = symbol_versioning.warn
87
# an example of the kind of thing plugins might want to do through
88
# the old interface - make a new option and then give it a short
90
symbol_versioning.set_warning_method(capture_warning)
91
working_tree_opt = option.Option('working tree', help='example option')
92
option.Option.SHORT_OPTIONS['w'] = working_tree_opt
93
self.assertEqual(working_tree_opt.short_name(), 'w')
94
self.assertEqual([expected_warning], _warnings)
96
symbol_versioning.set_warning_method(old_warning_method)
72
98
def test_allow_dash(self):
73
99
"""Test that we can pass a plain '-' as an argument."""
74
100
self.assertEqual((['-'], {}), parse_args(cmd_commit(), ['-']))