~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2009-08-26 16:03:59 UTC
  • mto: (4634.6.7 2.0)
  • mto: This revision was merged to the branch mainline in revision 4660.
  • Revision ID: john@arbash-meinel.com-20090826160359-ge4mai928bi3a5g2
Fix bug #419241. If a graph had a mainline ghost
we could get a segfault during KnownGraph.merge_sort().

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 by Canonical Ltd
 
1
# Copyright (C) 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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
"""Black-box tests for bzr whoami."""
32
32
        self.assertTrue(len(out) > 0)
33
33
        self.assertEquals(1, out.count('@'))
34
34
 
35
 
        out = self.run_bzr("whoami", "--email")[0]
 
35
        out = self.run_bzr("whoami --email")[0]
36
36
        self.assertTrue(len(out) > 0)
37
37
        self.assertEquals(1, out.count('@'))
38
 
        
 
38
 
39
39
    def test_whoami_branch(self):
40
40
        """branch specific user identity works."""
41
41
        wt = self.make_branch_and_tree('.')
45
45
        bzr_email = os.environ.get('BZR_EMAIL')
46
46
        if bzr_email is not None:
47
47
            del os.environ['BZR_EMAIL']
48
 
        bzremail = os.environ.get('BZREMAIL')
49
 
        if bzremail is not None:
50
 
            del os.environ['BZREMAIL']
51
48
        try:
52
49
            whoami = self.run_bzr("whoami")[0]
53
50
            self.assertEquals('Branch Identity <branch@identi.ty>\n', whoami)
54
 
            whoami_email = self.run_bzr("whoami", "--email")[0]
 
51
            whoami_email = self.run_bzr("whoami --email")[0]
55
52
            self.assertEquals('branch@identi.ty\n', whoami_email)
56
53
 
57
 
            # Verify that the environment variable overrides the value 
 
54
            # Verify that the environment variable overrides the value
58
55
            # in the file
59
56
            os.environ['BZR_EMAIL'] = 'Different ID <other@environ.ment>'
60
57
            whoami = self.run_bzr("whoami")[0]
61
58
            self.assertEquals('Different ID <other@environ.ment>\n', whoami)
62
 
            whoami_email = self.run_bzr("whoami", "--email")[0]
 
59
            whoami_email = self.run_bzr("whoami --email")[0]
63
60
            self.assertEquals('other@environ.ment\n', whoami_email)
64
61
            del os.environ['BZR_EMAIL']
65
 
            os.environ['BZREMAIL'] = 'Yet Another ID <yetother@environ.ment>'
66
 
            whoami, warn = self.run_bzr("whoami")
67
 
            self.assertEquals('Yet Another ID <yetother@environ.ment>\n', whoami)
68
 
            self.assertTrue(len(warn) > 0)
69
 
            del os.environ['BZREMAIL']
70
62
        finally:
71
63
            if bzr_email is not None:
72
64
                os.environ['BZR_EMAIL'] = bzr_email
73
 
            if bzremail is not None:
74
 
                os.environ['BZREMAIL'] = bzremail
75
65
 
76
66
    def test_whoami_utf8(self):
77
67
        """verify that an identity can be in utf-8."""
78
68
        wt = self.make_branch_and_tree('.')
79
 
        self.run_bzr('whoami', u'Branch Identity \u20ac <branch@identi.ty>',
 
69
        self.run_bzr(['whoami', u'Branch Identity \u20ac <branch@identi.ty>'],
80
70
                     encoding='utf-8')
81
71
        bzr_email = os.environ.get('BZR_EMAIL')
82
72
        if bzr_email is not None:
85
75
            whoami = self.run_bzr("whoami", encoding='utf-8')[0]
86
76
            self.assertEquals('Branch Identity \xe2\x82\xac ' +
87
77
                              '<branch@identi.ty>\n', whoami)
88
 
            whoami_email = self.run_bzr("whoami", "--email",
 
78
            whoami_email = self.run_bzr("whoami --email",
89
79
                                        encoding='utf-8')[0]
90
80
            self.assertEquals('branch@identi.ty\n', whoami_email)
91
81
        finally:
107
97
        try:
108
98
            whoami = self.run_bzr("whoami", encoding='ascii')[0]
109
99
            self.assertEquals('Branch Identity ? <branch@identi.ty>\n', whoami)
110
 
            whoami_email = self.run_bzr("whoami", "--email",
 
100
            whoami_email = self.run_bzr("whoami --email",
111
101
                                        encoding='ascii')[0]
112
102
            self.assertEquals('branch@identi.ty\n', whoami_email)
113
103
        finally:
117
107
    def test_warning(self):
118
108
        """verify that a warning is displayed if no email is given."""
119
109
        self.make_branch_and_tree('.')
120
 
        display = self.run_bzr('whoami', 'Branch Identity')[1]
 
110
        display = self.run_bzr(['whoami', 'Branch Identity'])[1]
121
111
        self.assertEquals('"Branch Identity" does not seem to contain an '
122
112
                          'email address.  This is allowed, but not '
123
113
                          'recommended.\n', display)