/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Martin
  • Date: 2019-06-16 17:36:59 UTC
  • mto: This revision was merged to the branch mainline in revision 7346.
  • Revision ID: gzlist@googlemail.com-20190616173659-rg7ps0f3wfiocsdm
Fix tests that need whoami not to be set

Add override_whoami helper that ensures whoami is not set. Had false
passes due to incomplete test isolation after rename.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Black-box tests for brz whoami."""
19
19
 
20
 
import breezy
21
20
from breezy import (
22
21
    branch,
23
22
    config,
26
25
    )
27
26
from breezy.sixish import PY3
28
27
 
 
28
from ..test_bedding import override_whoami
 
29
 
29
30
 
30
31
class TestWhoami(tests.TestCaseWithTransport):
31
32
 
60
61
    def test_whoami_branch(self):
61
62
        """branch specific user identity works."""
62
63
        wt = self.make_branch_and_tree('.')
63
 
        b = breezy.branch.Branch.open('.')
 
64
        b = branch.Branch.open('.')
64
65
        self.set_branch_email(b, 'Branch Identity <branch@identi.ty>')
65
66
        self.assertWhoAmI('Branch Identity <branch@identi.ty>')
66
67
        self.assertWhoAmI('branch@identi.ty', '--email')
85
86
        encoding.
86
87
        """
87
88
        wt = self.make_branch_and_tree('.')
88
 
        b = breezy.branch.Branch.open('.')
 
89
        b = branch.Branch.open('.')
89
90
        self.set_branch_email(b, u'Branch Identity \u20ac <branch@identi.ty>')
90
91
        self.assertWhoAmI('Branch Identity ? <branch@identi.ty>',
91
92
                          encoding='ascii')
103
104
    def test_whoami_not_set(self):
104
105
        """Ensure whoami error if username is not set and not inferred.
105
106
        """
106
 
        self.overrideEnv('EMAIL', None)
107
 
        self.overrideEnv('BRZ_EMAIL', None)
108
 
        # Also, make sure that it's not inferred from mailname.
109
 
        self.overrideAttr(config, '_auto_user_id', lambda: (None, None))
 
107
        override_whoami(self)
110
108
        out, err = self.run_bzr(['whoami'], 3)
111
109
        self.assertContainsRe(err, 'Unable to determine your name')
112
110
 
141
139
                         c.get('email'))
142
140
        # Ensuring that the value does not come from the breezy.conf file
143
141
        # itself requires some isolation setup
144
 
        self.overrideEnv('BRZ_EMAIL', None)
145
 
        self.overrideEnv('EMAIL', None)
146
 
        self.overrideAttr(config, '_auto_user_id', lambda: (None, None))
 
142
        override_whoami(self)
147
143
        global_conf = config.GlobalStack()
148
144
        self.assertRaises(errors.NoWhoami, global_conf.get, 'email')
149
145