/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 bzrlib/tests/test_version.py

  • Committer: Robert Collins
  • Date: 2010-05-06 23:41:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506234135-yivbzczw1sejxnxc
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
expected to return an object which can be used to unlock them. This reduces
duplicate code when using cleanups. The previous 'tokens's returned by
``Branch.lock_write`` and ``Repository.lock_write`` are now attributes
on the result of the lock_write. ``repository.RepositoryWriteLockResult``
and ``branch.BranchWriteLockResult`` document this. (Robert Collins)

``log._get_info_for_log_files`` now takes an add_cleanup callable.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2009, 2010, 2011 Canonical Ltd
 
1
# Copyright (C) 2006, 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
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""Tests for versioning of breezy."""
 
17
"""Tests for versioning of bzrlib."""
18
18
 
19
 
import platform
 
19
from cStringIO import StringIO
 
20
import os
20
21
import re
21
22
 
22
 
from .. import (
23
 
    tests,
24
 
    version,
25
 
    workingtree,
26
 
    )
27
 
from ..sixish import (
28
 
    PY3,
29
 
    StringIO,
30
 
    )
31
 
from .scenarios import load_tests_apply_scenarios
32
 
 
33
 
 
34
 
load_tests = load_tests_apply_scenarios
35
 
 
36
 
 
37
 
class TestBzrlibVersioning(tests.TestCase):
38
 
 
39
 
    def test_get_brz_source_tree(self):
 
23
from bzrlib import version, workingtree
 
24
from bzrlib.tests import TestCase, TestSkipped
 
25
 
 
26
class TestBzrlibVersioning(TestCase):
 
27
 
 
28
    def test_get_bzr_source_tree(self):
40
29
        """Get tree for bzr source, if any."""
41
30
        self.permit_source_tree_branch_repo()
42
31
        # We don't know if these tests are being run from a checkout or branch
43
32
        # of bzr, from an installed copy, or from source unpacked from a
44
33
        # tarball.  We don't construct a branch just for testing this, so we
45
34
        # just assert that it must either return None or the tree.
46
 
        src_tree = version._get_brz_source_tree()
 
35
        src_tree = version._get_bzr_source_tree()
47
36
        if src_tree is None:
48
 
            raise tests.TestSkipped(
49
 
                "bzr tests aren't run from a bzr working tree")
 
37
            raise TestSkipped("bzr tests aren't run from a bzr working tree")
50
38
        else:
51
39
            # ensure that what we got was in fact a working tree instance.
52
40
            self.assertIsInstance(src_tree, workingtree.WorkingTree)
55
43
        self.permit_source_tree_branch_repo()
56
44
        sio = StringIO()
57
45
        version.show_version(show_config=False, show_copyright=False,
58
 
                             to_file=sio)
 
46
            to_file=sio)
59
47
        out = sio.getvalue()
60
48
        m = re.search(r"Python interpreter: (.*) [0-9]", out)
61
49
        self.assertIsNot(m, None)
62
 
        self.assertPathExists(m.group(1))
63
 
 
64
 
 
65
 
class TestPlatformUse(tests.TestCase):
66
 
 
67
 
    scenarios = [('ascii', dict(_platform='test-platform')),
68
 
                 ('unicode', dict(_platform='Schr\xc3\xb6dinger'))]
69
 
 
70
 
    def setUp(self):
71
 
        super(TestPlatformUse, self).setUp()
72
 
        self.permit_source_tree_branch_repo()
73
 
 
74
 
    def test_platform(self):
75
 
        out = self.make_utf8_encoded_stringio()
76
 
        self.overrideAttr(platform, 'platform', lambda **
77
 
                          kwargs: self._platform)
78
 
        version.show_version(show_config=False, show_copyright=False,
79
 
                             to_file=out)
80
 
        expected = r'(?m)^  Platform: %s' % self._platform
81
 
        if PY3:
82
 
            expected = expected.encode('utf-8')
83
 
        self.assertContainsRe(out.getvalue(), expected)
 
50
        self.failUnlessExists(m.group(1))