~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: 2011-05-11 11:35:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5851.
  • Revision ID: john@arbash-meinel.com-20110511113528-qepibuwxicjrbb2h
Break compatibility with python <2.6.

This includes auditing the code for places where we were doing
explicit 'sys.version' checks and removing them as appropriate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009, 2010, 2011 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
17
17
 
18
18
"""Black-box tests for bzr whoami."""
19
19
 
20
 
import os
21
 
 
22
20
import bzrlib
23
21
from bzrlib import (
24
 
    osutils,
25
22
    config,
26
23
    )
27
24
from bzrlib.tests import TestCaseWithTransport
39
36
        self.assertTrue(len(out) > 0)
40
37
        self.assertEquals(1, out.count('@'))
41
38
 
 
39
    def test_whoami_email_arg(self):
 
40
        # whoami --email is mutually exclusive with any arguments
 
41
        out = self.run_bzr("whoami --email 'foo <foo@example.com>'", 3)[0]
 
42
        self.assertEquals("", out)
 
43
 
42
44
    def test_whoami_branch(self):
43
45
        """branch specific user identity works."""
44
46
        wt = self.make_branch_and_tree('.')
52
54
 
53
55
        # Verify that the environment variable overrides the value
54
56
        # in the file
55
 
        os.environ['BZR_EMAIL'] = 'Different ID <other@environ.ment>'
 
57
        self.overrideEnv('BZR_EMAIL', 'Different ID <other@environ.ment>')
56
58
        whoami = self.run_bzr("whoami")[0]
57
59
        self.assertEquals('Different ID <other@environ.ment>\n', whoami)
58
60
        whoami_email = self.run_bzr("whoami --email")[0]
92
94
                          'recommended.\n', display)
93
95
 
94
96
    def test_whoami_not_set(self):
95
 
        """Ensure whoami error if username is not set.
 
97
        """Ensure whoami error if username is not set and not inferred.
96
98
        """
97
 
        osutils.set_or_unset_env('EMAIL', None)
98
 
        osutils.set_or_unset_env('BZR_EMAIL', None)
 
99
        self.overrideEnv('EMAIL', None)
 
100
        self.overrideEnv('BZR_EMAIL', None)
 
101
        # Also, make sure that it's not inferred from mailname.
 
102
        self.overrideAttr(config, '_auto_user_id',
 
103
            lambda: (None, None))
99
104
        out, err = self.run_bzr(['whoami'], 3)
100
105
        self.assertContainsRe(err, 'Unable to determine your name')
101
106