/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/tests/test_branch.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
also see this file.
23
23
"""
24
24
 
25
 
from cStringIO import StringIO
26
 
 
27
 
from bzrlib import (
 
25
from .. import (
28
26
    branch as _mod_branch,
29
27
    bzrdir,
30
28
    config,
34
32
    trace,
35
33
    urlutils,
36
34
    )
37
 
from bzrlib.branchfmt.fullhistory import (
 
35
from ..branchfmt.fullhistory import (
38
36
    BzrBranch5,
39
37
    BzrBranchFormat5,
40
38
    )
 
39
from ..sixish import (
 
40
    BytesIO,
 
41
    )
41
42
 
42
43
 
43
44
class TestDefaultFormat(tests.TestCase):
195
196
        SampleSupportedBranchFormat().initialize(dir)
196
197
        factory = _mod_branch.MetaDirBranchFormatFactory(
197
198
            SampleSupportedBranchFormatString,
198
 
            "bzrlib.tests.test_branch", "SampleSupportedBranchFormat")
 
199
            "breezy.tests.test_branch", "SampleSupportedBranchFormat")
199
200
        _mod_branch.format_registry.register(factory)
200
201
        self.addCleanup(_mod_branch.format_registry.remove, factory)
201
202
        b = _mod_branch.Branch.open(self.get_url())
267
268
 
268
269
    def test_register_extra_lazy(self):
269
270
        self.assertEqual([], self.registry._get_all())
270
 
        self.registry.register_extra_lazy("bzrlib.tests.test_branch",
 
271
        self.registry.register_extra_lazy("breezy.tests.test_branch",
271
272
            "SampleExtraBranchFormat")
272
273
        formats = self.registry._get_all()
273
274
        self.assertEqual(1, len(formats))
291
292
        global FakeLazyFormat
292
293
        del FakeLazyFormat
293
294
        factory = _mod_branch.MetaDirBranchFormatFactory(None,
294
 
            "bzrlib.tests.test_branch", "FakeLazyFormat")
 
295
            "breezy.tests.test_branch", "FakeLazyFormat")
295
296
        self.assertRaises(AttributeError, factory)
296
297
 
297
298
    def test_call_returns_call_of_referenced_object(self):
298
299
        global FakeLazyFormat
299
300
        FakeLazyFormat = lambda:'called'
300
301
        factory = _mod_branch.MetaDirBranchFormatFactory(None,
301
 
            "bzrlib.tests.test_branch", "FakeLazyFormat")
 
302
            "breezy.tests.test_branch", "FakeLazyFormat")
302
303
        self.assertEqual('called', factory())
303
304
 
304
305
 
596
597
        self.assertStartsWith(param_repr, '<BranchInitHookParams of ')
597
598
 
598
599
    def test_post_switch_hook(self):
599
 
        from bzrlib import switch
 
600
        from .. import switch
600
601
        calls = []
601
602
        _mod_branch.Branch.hooks.install_named_hook('post_switch',
602
603
            calls.append, None)
710
711
        r.old_revno = 10
711
712
        r.new_revid = "new-revid"
712
713
        r.new_revno = 20
713
 
        f = StringIO()
 
714
        f = BytesIO()
714
715
        r.report(f)
715
716
        self.assertEqual("Now on revision 20.\n", f.getvalue())
716
717
        self.assertEqual("Now on revision 20.\n", f.getvalue())
719
720
        r = _mod_branch.PullResult()
720
721
        r.old_revid = "same-revid"
721
722
        r.new_revid = "same-revid"
722
 
        f = StringIO()
 
723
        f = BytesIO()
723
724
        r.report(f)
724
725
        self.assertEqual("No revisions or tags to pull.\n", f.getvalue())