42
42
b = bzrlib.branch.Branch.open('.')
43
43
b.get_config().set_user_option('email',
44
44
'Branch Identity <branch@identi.ty>')
45
bzr_email = os.environ.get('BZREMAIL')
45
bzr_email = os.environ.get('BZR_EMAIL')
46
46
if bzr_email is not None:
47
del os.environ['BZR_EMAIL']
48
bzremail = os.environ.get('BZREMAIL')
49
if bzremail is not None:
47
50
del os.environ['BZREMAIL']
49
52
whoami = self.run_bzr("whoami")[0]
54
57
# Verify that the environment variable overrides the value
56
os.environ['BZREMAIL'] = 'Different ID <other@environ.ment>'
59
os.environ['BZR_EMAIL'] = 'Different ID <other@environ.ment>'
57
60
whoami = self.run_bzr("whoami")[0]
58
61
self.assertEquals('Different ID <other@environ.ment>\n', whoami)
59
62
whoami_email = self.run_bzr("whoami", "--email")[0]
60
63
self.assertEquals('other@environ.ment\n', whoami_email)
64
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']
62
71
if bzr_email is not None:
63
os.environ['BZREMAIL'] = bzr_email
72
os.environ['BZR_EMAIL'] = bzr_email
73
if bzremail is not None:
74
os.environ['BZREMAIL'] = bzremail
65
76
def test_whoami_utf8(self):
66
77
"""verify that an identity can be in utf-8."""
67
78
wt = self.make_branch_and_tree('.')
68
79
self.run_bzr('whoami', u'Branch Identity \u20ac <branch@identi.ty>',
70
bzr_email = os.environ.get('BZREMAIL')
81
bzr_email = os.environ.get('BZR_EMAIL')
71
82
if bzr_email is not None:
72
del os.environ['BZREMAIL']
83
del os.environ['BZR_EMAIL']
74
85
whoami = self.run_bzr("whoami", encoding='utf-8')[0]
75
86
self.assertEquals('Branch Identity \xe2\x82\xac ' +
79
90
self.assertEquals('branch@identi.ty\n', whoami_email)
81
92
if bzr_email is not None:
82
os.environ['BZREMAIL'] = bzr_email
93
os.environ['BZR_EMAIL'] = bzr_email
84
95
def test_whoami_ascii(self):
90
101
b = bzrlib.branch.Branch.open('.')
91
102
b.get_config().set_user_option('email', u'Branch Identity \u20ac ' +
92
103
'<branch@identi.ty>')
93
bzr_email = os.environ.get('BZREMAIL')
104
bzr_email = os.environ.get('BZR_EMAIL')
94
105
if bzr_email is not None:
95
del os.environ['BZREMAIL']
106
del os.environ['BZR_EMAIL']
97
108
whoami = self.run_bzr("whoami", encoding='ascii')[0]
98
109
self.assertEquals('Branch Identity ? <branch@identi.ty>\n', whoami)
101
112
self.assertEquals('branch@identi.ty\n', whoami_email)
103
114
if bzr_email is not None:
104
os.environ['BZREMAIL'] = bzr_email
115
os.environ['BZR_EMAIL'] = bzr_email
106
117
def test_warning(self):
107
118
"""verify that a warning is displayed if no email is given."""