~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_options.py

  • Committer: Martin Pool
  • Date: 2007-07-11 04:15:48 UTC
  • mto: This revision was merged to the branch mainline in revision 2605.
  • Revision ID: mbp@sourcefrog.net-20070711041548-n1om2ptyj2j01r6l
Clean up old/unused global options

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
        out, err = self.run_bzr('help -r', retcode=3)
75
75
        self.assertContainsRe(err, r'no such option')
76
76
 
77
 
    def test_get_short_name(self):
78
 
        file_opt = option.Option.OPTIONS['file']
79
 
        self.assertEquals(file_opt.short_name(), 'F')
80
 
        force_opt = option.Option.OPTIONS['force']
81
 
        self.assertEquals(force_opt.short_name(), None)
82
 
 
83
77
    def test_set_short_name(self):
84
78
        o = option.Option('wiggle')
85
79
        o.set_short_name('w')
86
80
        self.assertEqual(o.short_name(), 'w')
87
81
 
88
 
    def test_old_short_names(self):
89
 
        # test the deprecated method for getting and setting short option
90
 
        # names
91
 
        expected_warning = (
92
 
            "access to SHORT_OPTIONS was deprecated in version 0.14."
93
 
            " Set the short option name when constructing the Option.",
94
 
            DeprecationWarning, 2)
95
 
        _warnings = []
96
 
        def capture_warning(message, category, stacklevel=None):
97
 
            _warnings.append((message, category, stacklevel))
98
 
        old_warning_method = symbol_versioning.warn
99
 
        try:
100
 
            # an example of the kind of thing plugins might want to do through
101
 
            # the old interface - make a new option and then give it a short
102
 
            # name.
103
 
            symbol_versioning.set_warning_method(capture_warning)
104
 
            example_opt = option.Option('example', help='example option')
105
 
            option.Option.SHORT_OPTIONS['w'] = example_opt
106
 
            self.assertEqual(example_opt.short_name(), 'w')
107
 
            self.assertEqual([expected_warning], _warnings)
108
 
            # now check that it can actually be parsed with the registered
109
 
            # value
110
 
            opts, args = parse([example_opt], ['-w', 'foo'])
111
 
            self.assertEqual(opts.example, True)
112
 
            self.assertEqual(args, ['foo'])
113
 
        finally:
114
 
            symbol_versioning.set_warning_method(old_warning_method)
115
 
 
116
82
    def test_allow_dash(self):
117
83
        """Test that we can pass a plain '-' as an argument."""
118
84
        self.assertEqual(