~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Alexander Belchenko
  • Date: 2007-09-04 11:00:30 UTC
  • mto: This revision was merged to the branch mainline in revision 2800.
  • Revision ID: bialix@ukr.net-20070904110030-pma21wbsylstkdnv
support for non-ascii BZR_HOME in show_version()

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Black-box tests for bzr version."""
18
18
 
19
19
import bzrlib
20
 
from bzrlib.tests import TestCase
21
 
from bzrlib import trace
 
20
from bzrlib import osutils, trace
 
21
from bzrlib.tests import (
 
22
    probe_unicode_in_user_encoding,
 
23
    TestCase,
 
24
    TestCaseInTempDir,
 
25
    TestSkipped,
 
26
    )
22
27
 
23
28
 
24
29
class TestVersion(TestCase):
34
39
        self.assertContainsRe(out, r'(?m)^  Bazaar log file:.*bzr\.log')
35
40
 
36
41
 
37
 
class TestVersionUnicodeOutput(TestCase):
 
42
class TestVersionUnicodeOutput(TestCaseInTempDir):
38
43
 
39
44
    def _check(self, args):
 
45
        # Even though trace._bzr_log_filename variable
 
46
        # is used only to keep actual log filename
 
47
        # and changing this variable in selftest
 
48
        # don't change main .bzr.log location,
 
49
        # and therefore pretty safe,
 
50
        # but we run these tests in separate temp dir
 
51
        # with relative unicoded path
40
52
        old_trace_file = trace._bzr_log_filename
41
 
        trace._bzr_log_filename = u'/\u1234/.bzr.log'
 
53
        trace._bzr_log_filename = u'\u1234/.bzr.log'
42
54
        try:
43
55
            out = self.run_bzr(args)[0]
44
56
        finally:
45
57
            trace._bzr_log_filename = old_trace_file
46
58
        self.assertTrue(len(out) > 0)
47
 
        self.assertEquals(1, out.count(bzrlib.__version__))
48
 
        self.assertContainsRe(out, r"(?m)^  Python interpreter:")
49
 
        self.assertContainsRe(out, r"(?m)^  Python standard library:")
50
 
        self.assertContainsRe(out, r"(?m)^  bzrlib:")
51
 
        self.assertContainsRe(out, r"(?m)^  Bazaar configuration:")
52
59
        self.assertContainsRe(out, r'(?m)^  Bazaar log file:.*bzr\.log')
53
60
 
54
61
    def test_command(self):
56
63
 
57
64
    def test_flag(self):
58
65
        self._check("--version")
 
66
 
 
67
    def test_unicode_bzr_home(self):
 
68
        uni_val, str_val = probe_unicode_in_user_encoding()
 
69
        if uni_val is None:
 
70
            raise TestSkipped('Cannot find a unicode character that works in'
 
71
                              ' encoding %s' % (bzrlib.user_encoding,))
 
72
 
 
73
        osutils.set_or_unset_env('BZR_HOME', str_val)
 
74
        out = self.run_bzr("version")[0]
 
75
        self.assertTrue(len(out) > 0)
 
76
        self.assertContainsRe(out, r"(?m)^  Bazaar configuration: " + str_val)