~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
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']
48
51
        try:
49
52
            whoami = self.run_bzr("whoami")[0]
53
56
 
54
57
            # Verify that the environment variable overrides the value 
55
58
            # in the file
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']
61
70
        finally:
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
64
75
 
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>',
69
80
                     encoding='utf-8')
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']
73
84
        try:
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)
80
91
        finally:
81
92
            if bzr_email is not None:
82
 
                os.environ['BZREMAIL'] = bzr_email
 
93
                os.environ['BZR_EMAIL'] = bzr_email
83
94
 
84
95
    def test_whoami_ascii(self):
85
96
        """
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']
96
107
        try:
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)
102
113
        finally:
103
114
            if bzr_email is not None:
104
 
                os.environ['BZREMAIL'] = bzr_email
 
115
                os.environ['BZR_EMAIL'] = bzr_email
105
116
 
106
117
    def test_warning(self):
107
118
        """verify that a warning is displayed if no email is given."""