/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 breezy/tests/test_bzrdir.py

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 20:02:36 UTC
  • mto: (7490.7.7 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200322200236-fsbl91ktcn6fcbdd
Fix tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import subprocess
24
24
import sys
25
25
 
26
 
from ... import (
 
26
from .. import (
27
27
    branch,
28
28
    bzr,
29
29
    config,
38
38
    urlutils,
39
39
    win32utils,
40
40
    )
41
 
from .. import (
 
41
from ..bzr import (
42
42
    branch as bzrbranch,
43
43
    bzrdir,
44
44
    remote,
47
47
    )
48
48
import breezy.branch
49
49
import breezy.bzr.branch
50
 
from ..fullhistory import BzrBranchFormat5
51
 
from ...errors import (
 
50
from ..bzr.fullhistory import BzrBranchFormat5
 
51
from ..errors import (
52
52
    NotBranchError,
53
53
    NoColocatedBranchSupport,
54
54
    UnknownFormatError,
55
55
    UnsupportedFormatError,
56
56
    )
57
 
from ...tests import (
 
57
from . import (
58
58
    TestCase,
59
59
    TestCaseWithMemoryTransport,
60
60
    TestCaseWithTransport,
61
61
    TestSkipped,
62
62
    )
63
 
from ...tests import (
 
63
from . import (
64
64
    http_server,
65
65
    http_utils,
66
66
    )
67
 
from ...transport import (
 
67
from ..transport import (
68
68
    memory,
69
69
    pathfilter,
70
70
    )
71
 
from ...transport.http import HttpTransport
72
 
from ...transport.nosmart import NoSmartTransportDecorator
73
 
from ...transport.readonly import ReadonlyTransportDecorator
74
 
from .. import knitrepo, knitpack_repo
 
71
from ..transport.http import HttpTransport
 
72
from ..transport.nosmart import NoSmartTransportDecorator
 
73
from ..transport.readonly import ReadonlyTransportDecorator
 
74
from ..bzr import knitrepo, knitpack_repo
75
75
 
76
76
 
77
77
class TestDefaultFormat(TestCase):
101
101
        my_format_registry.register('deprecated', DeprecatedBzrDirFormat,
102
102
                                    'Some format.  Slower and unawesome and deprecated.',
103
103
                                    deprecated=True)
104
 
        my_format_registry.register_lazy('lazy', __name__,
 
104
        my_format_registry.register_lazy('lazy', 'breezy.tests.test_bzrdir',
105
105
                                         'DeprecatedBzrDirFormat', 'Format registered lazily',
106
106
                                         deprecated=True)
107
107
        bzr.register_metadir(my_format_registry, 'knit',
122
122
                             branch_format='breezy.bzr.branch.BzrBranchFormat6', hidden=True)
123
123
        my_format_registry.register('hiddendeprecated', DeprecatedBzrDirFormat,
124
124
                                    'Old format.  Slower and does not support things. ', hidden=True)
125
 
        my_format_registry.register_lazy('hiddenlazy', __name__,
 
125
        my_format_registry.register_lazy('hiddenlazy', 'breezy.tests.test_bzrdir',
126
126
                                         'DeprecatedBzrDirFormat', 'Format registered lazily',
127
127
                                         deprecated=True, hidden=True)
128
128
        return my_format_registry
318
318
        t = self.get_transport()
319
319
        t.mkdir('.bzr')
320
320
        t.put_bytes('.bzr/branch-format', b'Corrupt line endings\r\n')
321
 
        self.assertRaises(bzr.LineEndingError,
 
321
        self.assertRaises(errors.LineEndingError,
322
322
                          bzrdir.BzrDirFormat.find_format,
323
323
                          _mod_transport.get_transport_from_path('.'))
324
324
 
325
 
    def test_find_format_html(self):
326
 
        t = self.get_transport()
327
 
        t.mkdir('.bzr')
328
 
        t.put_bytes(
329
 
            '.bzr/branch-format',
330
 
            b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">')
331
 
        e = self.assertRaises(
332
 
            NotBranchError, bzrdir.BzrDirFormat.find_format,
333
 
            _mod_transport.get_transport_from_path('.'))
334
 
 
335
325
    def test_register_unregister_format(self):
336
326
        format = SampleBzrDirFormat()
337
327
        url = self.get_url()
831
821
        self.assertEqual(os.path.realpath('topdir/foo'),
832
822
                         self.local_branch_path(branch))
833
823
 
834
 
    def test_open_tree_or_branch_named(self):
835
 
        tree = self.make_branch_and_tree('topdir')
836
 
        self.assertRaises(
837
 
            NotBranchError,
838
 
            bzrdir.BzrDir.open_tree_or_branch, 'topdir', name='missing')
839
 
        tree.branch.controldir.create_branch('named')
840
 
        tree, branch = bzrdir.BzrDir.open_tree_or_branch('topdir', name='named')
841
 
        self.assertEqual(os.path.realpath('topdir'),
842
 
                         os.path.realpath(tree.basedir))
843
 
        self.assertEqual(os.path.realpath('topdir'),
844
 
                         self.local_branch_path(branch))
845
 
        self.assertEqual(branch.name, 'named')
846
 
        self.assertIs(tree.controldir, branch.controldir)
847
 
 
848
824
    def test_open_from_transport(self):
849
825
        # transport pointing at bzrdir should give a bzrdir with root transport
850
826
        # set to the given transport
1403
1379
        self.assertEqual('fail', err._preformatted_string)
1404
1380
 
1405
1381
    def test_post_repo_init(self):
1406
 
        from ...controldir import RepoInitHookParams
 
1382
        from ..controldir import RepoInitHookParams
1407
1383
        calls = []
1408
1384
        bzrdir.BzrDir.hooks.install_named_hook('post_repo_init',
1409
1385
                                               calls.append, None)