~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_help.py

  • Committer: Vincent Ladeuil
  • Date: 2009-04-27 16:10:10 UTC
  • mto: (4310.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4311.
  • Revision ID: v.ladeuil+lp@free.fr-20090427161010-7swfzeagf63cpixd
Fix bug #367726 by reverting some default user handling introduced
while fixing bug #256612.

* bzrlib/transport/ssh.py:
(_paramiko_auth): Explicitly use getpass.getuser() as default
user.

* bzrlib/transport/ftp/_gssapi.py:
(GSSAPIFtpTransport._create_connection): Explicitly use
getpass.getuser() as default user.

* bzrlib/transport/ftp/__init__.py:
(FtpTransport._create_connection): Explicitly use
getpass.getuser() as default user.

* bzrlib/tests/test_sftp_transport.py:
(TestUsesAuthConfig.test_sftp_is_none_if_no_config)
(TestUsesAuthConfig.test_sftp_doesnt_prompt_username): Revert to
None as the default user.

* bzrlib/tests/test_remote.py:
(TestRemoteSSHTransportAuthentication): The really offending one:
revert to None as the default user.

* bzrlib/tests/test_config.py:
(TestAuthenticationConfig.test_username_default_no_prompt): Update
test (and some PEP8).

* bzrlib/smtp_connection.py:
(SMTPConnection._authenticate): Revert to None as the default
user.

* bzrlib/plugins/launchpad/account.py:
(_get_auth_user): Revert default value handling.

* bzrlib/config.py:
(AuthenticationConfig.get_user): Fix doc-string. Leave default
value handling to callers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
#
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
20
20
 
21
21
 
22
22
import bzrlib
23
 
from bzrlib import config
24
 
from bzrlib.tests import TestCaseWithTransport
25
 
 
26
 
 
27
 
class TestHelp(TestCaseWithTransport):
 
23
from bzrlib.tests.blackbox import ExternalBase
 
24
from bzrlib.config import (ensure_config_dir_exists, config_filename)
 
25
 
 
26
 
 
27
class TestHelp(ExternalBase):
28
28
 
29
29
    def test_help_basic(self):
30
30
        for cmd in ['--help', 'help', '-h', '-?']:
105
105
        self.assertEquals(dash_help, qmark_cmds)
106
106
 
107
107
    def test_hidden(self):
108
 
        help_commands = self.run_bzr('help commands')[0]
109
 
        help_hidden = self.run_bzr('help hidden-commands')[0]
110
 
 
111
 
        def extract_cmd_names(help_output):
112
 
            # keep only the command names to avoid matching on help text (there
113
 
            # is a high risk to fail a test when a plugin get installed
114
 
            # otherwise)
115
 
            cmds = []
116
 
            for line in help_output.split('\n'):
117
 
                if line.startswith(' '):
118
 
                    continue # help on more than one line
119
 
                cmd = line.split(' ')[0]
120
 
                if line:
121
 
                    cmds.append(cmd)
122
 
            return cmds
123
 
        commands = extract_cmd_names(help_commands)
124
 
        hidden = extract_cmd_names(help_hidden)
 
108
        commands = self.run_bzr('help commands')[0]
 
109
        hidden = self.run_bzr('help hidden-commands')[0]
125
110
        self.assertTrue('commit' in commands)
126
111
        self.assertTrue('commit' not in hidden)
127
112
        self.assertTrue('rocks' in hidden)
161
146
    def test_help_with_aliases(self):
162
147
        original = self.run_bzr('help cat')[0]
163
148
 
164
 
        conf = config.GlobalConfig.from_string('''[ALIASES]
165
 
c=cat
166
 
cat=cat
167
 
''', save=True)
 
149
        ensure_config_dir_exists()
 
150
        CONFIG=("[ALIASES]\n"
 
151
        "c=cat\n"
 
152
        "cat=cat\n")
 
153
 
 
154
        open(config_filename(),'wb').write(CONFIG)
168
155
 
169
156
        expected = original + "'bzr cat' is an alias for 'bzr cat'.\n"
170
157
        self.assertEqual(expected, self.run_bzr('help cat')[0])