40
40
"""branch specific user identity works."""
41
41
wt = self.make_branch_and_tree('.')
42
42
b = bzrlib.branch.Branch.open('.')
43
b.get_config().set_user_option('email', 'Branch Identity <branch@identi.ty>')
43
b.get_config().set_user_option('email',
44
'Branch Identity <branch@identi.ty>')
44
45
bzr_email = os.environ.get('BZREMAIL')
45
46
if bzr_email is not None:
46
47
del os.environ['BZREMAIL']
64
65
def test_whoami_utf8(self):
65
66
"""verify that an identity can be in utf-8."""
66
67
wt = self.make_branch_and_tree('.')
67
self.run_bzr('whoami', u'Branch Identity \u20ac <branch@identi.ty>', encoding='utf-8')
68
self.run_bzr('whoami', u'Branch Identity \u20ac <branch@identi.ty>',
68
70
bzr_email = os.environ.get('BZREMAIL')
69
71
if bzr_email is not None:
70
72
del os.environ['BZREMAIL']
72
74
whoami = self.run_bzr("whoami", encoding='utf-8')[0]
73
self.assertEquals('Branch Identity \xe2\x82\xac <branch@identi.ty>\n', whoami)
74
whoami_email = self.run_bzr("whoami", "--email", encoding='utf-8')[0]
75
self.assertEquals('Branch Identity \xe2\x82\xac ' +
76
'<branch@identi.ty>\n', whoami)
77
whoami_email = self.run_bzr("whoami", "--email",
75
79
self.assertEquals('branch@identi.ty\n', whoami_email)
77
81
if bzr_email is not None:
78
82
os.environ['BZREMAIL'] = bzr_email
80
84
def test_whoami_ascii(self):
81
"""verify that whoami doesn't totally break when in utf-8, using an ascii encoding."""
86
verify that whoami doesn't totally break when in utf-8, using an ascii
82
89
wt = self.make_branch_and_tree('.')
83
90
b = bzrlib.branch.Branch.open('.')
84
b.get_config().set_user_option('email', u'Branch Identity \u20ac <branch@identi.ty>')
91
b.get_config().set_user_option('email', u'Branch Identity \u20ac ' +
85
93
bzr_email = os.environ.get('BZREMAIL')
86
94
if bzr_email is not None:
87
95
del os.environ['BZREMAIL']
89
97
whoami = self.run_bzr("whoami", encoding='ascii')[0]
90
98
self.assertEquals('Branch Identity ? <branch@identi.ty>\n', whoami)
91
whoami_email = self.run_bzr("whoami", "--email", encoding='ascii')[0]
99
whoami_email = self.run_bzr("whoami", "--email",
92
101
self.assertEquals('branch@identi.ty\n', whoami_email)
94
103
if bzr_email is not None:
95
104
os.environ['BZREMAIL'] = bzr_email
106
def test_warning(self):
107
"""verify that a warning is displayed if no email is given."""
108
self.make_branch_and_tree('.')
109
display = self.run_bzr('whoami', 'Branch Identity')[1]
110
self.assertEquals('"Branch Identity" does not seem to contain an '
111
'email address. This is allowed, but not '
112
'recommended.\n', display)