~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-11-08 13:45:51 UTC
  • mfrom: (5532.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20101108134551-sxvk77ehmegkrwmm
(vila) Fix news entry

Show diffs side-by-side

added added

removed removed

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