~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2010-04-23 08:51:52 UTC
  • mfrom: (5131.2.6 support_OO_flag)
  • mto: This revision was merged to the branch mainline in revision 5179.
  • Revision ID: v.ladeuil+lp@free.fr-20100423085152-uoewc1vnkwqhw0pj
Manually assign docstrings to command objects, so that they work with python -OO

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006-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
22
22
 
23
23
from bzrlib import (
24
24
    branch as _mod_branch,
 
25
    osutils,
25
26
    urlutils,
26
27
    )
27
28
from bzrlib.bzrdir import BzrDirMetaFormat1
33
34
 
34
35
class TestInit(ExternalBase):
35
36
 
 
37
    def setUp(self):
 
38
        ExternalBase.setUp(self)
 
39
        self._default_label = '2a'
 
40
 
36
41
    def test_init_with_format(self):
37
42
        # Verify bzr init --format constructs something plausible
38
43
        t = self.get_transport()
49
54
            out)
50
55
        self.assertEqual('', err)
51
56
 
 
57
    def test_init_format_2a(self):
 
58
        """Smoke test for constructing a format 2a repoistory."""
 
59
        out, err = self.run_bzr('init --format=2a')
 
60
        self.assertEqual("""Created a standalone tree (format: 2a)\n""",
 
61
            out)
 
62
        self.assertEqual('', err)
 
63
 
52
64
    def test_init_at_repository_root(self):
53
65
        # bzr init at the root of a repository should create a branch
54
66
        # and working tree even when creation of working trees is disabled.
59
71
        repo = newdir.create_repository(shared=True)
60
72
        repo.set_make_working_trees(False)
61
73
        out, err = self.run_bzr('init repo')
62
 
        self.assertEqual("""Created a repository tree (format: pack-0.92)
 
74
        self.assertEqual("""Created a repository tree (format: %s)
63
75
Using shared repository: %s
64
 
""" % urlutils.local_path_from_url(
65
 
            repo.bzrdir.root_transport.external_url()), out)
66
 
        self.assertEndsWith(out, "bzrlib.tests.blackbox.test_init.TestInit."
67
 
            "test_init_at_repository_root/work/repo/\n")
 
76
""" % (self._default_label, urlutils.local_path_from_url(
 
77
            repo.bzrdir.root_transport.external_url())), out)
 
78
        cwd = osutils.getcwd()
 
79
        self.assertEndsWith(out, cwd + '/repo/\n')
68
80
        self.assertEqual('', err)
69
81
        newdir.open_branch()
70
82
        newdir.open_workingtree()
71
83
 
72
84
    def test_init_branch(self):
73
85
        out, err = self.run_bzr('init')
74
 
        self.assertEqual("""Created a standalone tree (format: pack-0.92)\n""",
75
 
            out)
 
86
        self.assertEqual("Created a standalone tree (format: %s)\n" % (
 
87
            self._default_label,), out)
76
88
        self.assertEqual('', err)
77
89
 
78
90
        # Can it handle subdirectories of branches too ?
79
91
        out, err = self.run_bzr('init subdir1')
80
 
        self.assertEqual("""Created a standalone tree (format: pack-0.92)\n""",
81
 
            out)
 
92
        self.assertEqual("Created a standalone tree (format: %s)\n" % (
 
93
            self._default_label,), out)
82
94
        self.assertEqual('', err)
83
95
        WorkingTree.open('subdir1')
84
96
 
89
101
 
90
102
        os.mkdir('subdir2')
91
103
        out, err = self.run_bzr('init subdir2')
92
 
        self.assertEqual("""Created a standalone tree (format: pack-0.92)\n""",
93
 
            out)
 
104
        self.assertEqual("Created a standalone tree (format: %s)\n" % (
 
105
            self._default_label,), out)
94
106
        self.assertEqual('', err)
95
107
        # init an existing branch.
96
108
        out, err = self.run_bzr('init subdir2', retcode=3)
156
168
 
157
169
    def test_init(self):
158
170
        # init on a remote url should succeed.
159
 
        out, err = self.run_bzr(['init', self.get_url()])
 
171
        out, err = self.run_bzr(['init', '--pack-0.92', self.get_url()])
160
172
        self.assertEqual(out,
161
173
            """Created a standalone branch (format: pack-0.92)\n""")
162
174
        self.assertEqual('', err)
184
196
    def test_init_append_revisions_only(self):
185
197
        self.run_bzr('init --dirstate-tags normal_branch6')
186
198
        branch = _mod_branch.Branch.open('normal_branch6')
187
 
        self.assertEqual(False, branch._get_append_revisions_only())
 
199
        self.assertEqual(None, branch._get_append_revisions_only())
188
200
        self.run_bzr('init --append-revisions-only --dirstate-tags branch6')
189
201
        branch = _mod_branch.Branch.open('branch6')
190
202
        self.assertEqual(True, branch._get_append_revisions_only())