/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/__init__.py

(Martin von Gagern) Deal with branch: revision specs in readonly
        transactions

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
from bzrlib.tests import (
113
113
    test_server,
114
114
    TestUtil,
 
115
    treeshape,
115
116
    )
116
117
from bzrlib.tests.http_server import HttpServer
117
118
from bzrlib.tests.TestUtil import (
118
119
                          TestSuite,
119
120
                          TestLoader,
120
121
                          )
121
 
from bzrlib.tests.treeshape import build_tree_contents
122
122
from bzrlib.ui import NullProgressView
123
123
from bzrlib.ui.text import TextUIFactory
124
124
import bzrlib.version_info_formats.format_custom
749
749
    # XXX: Should probably unify more with CannedInputUIFactory or a
750
750
    # particular configuration of TextUIFactory, or otherwise have a clearer
751
751
    # idea of how they're supposed to be different.
752
 
    # See https://bugs.edge.launchpad.net/bzr/+bug/408213
 
752
    # See https://bugs.launchpad.net/bzr/+bug/408213
753
753
 
754
754
    def __init__(self, stdout=None, stderr=None, stdin=None):
755
755
        if stdin is not None:
1524
1524
            'EDITOR': None,
1525
1525
            'BZR_EMAIL': None,
1526
1526
            'BZREMAIL': None, # may still be present in the environment
1527
 
            'EMAIL': None,
 
1527
            'EMAIL': 'jrandom@example.com', # set EMAIL as bzr does not guess
1528
1528
            'BZR_PROGRESS_BAR': None,
1529
1529
            'BZR_LOG': None,
1530
1530
            'BZR_PLUGIN_PATH': None,
2408
2408
        made_control = self.make_bzrdir(relpath, format=format)
2409
2409
        return made_control.create_repository(shared=shared)
2410
2410
 
2411
 
    def make_smart_server(self, path):
 
2411
    def make_smart_server(self, path, backing_server=None):
 
2412
        if backing_server is None:
 
2413
            backing_server = self.get_server()
2412
2414
        smart_server = test_server.SmartTCPServer_for_testing()
2413
 
        self.start_server(smart_server, self.get_server())
 
2415
        self.start_server(smart_server, backing_server)
2414
2416
        remote_transport = get_transport(smart_server.get_url()).clone(path)
2415
2417
        return remote_transport
2416
2418
 
2482
2484
 
2483
2485
    def check_file_contents(self, filename, expect):
2484
2486
        self.log("check contents of file %s" % filename)
2485
 
        contents = file(filename, 'r').read()
 
2487
        f = file(filename)
 
2488
        try:
 
2489
            contents = f.read()
 
2490
        finally:
 
2491
            f.close()
2486
2492
        if contents != expect:
2487
2493
            self.log("expected: %r" % expect)
2488
2494
            self.log("actually: %r" % contents)
2578
2584
                content = "contents of %s%s" % (name.encode('utf-8'), end)
2579
2585
                transport.put_bytes_non_atomic(urlutils.escape(name), content)
2580
2586
 
2581
 
    def build_tree_contents(self, shape):
2582
 
        build_tree_contents(shape)
 
2587
    build_tree_contents = staticmethod(treeshape.build_tree_contents)
2583
2588
 
2584
2589
    def assertInWorkingTree(self, path, root_path='.', tree=None):
2585
2590
        """Assert whether path or paths are in the WorkingTree"""
3701
3706
        'bzrlib.tests.test_export',
3702
3707
        'bzrlib.tests.test_extract',
3703
3708
        'bzrlib.tests.test_fetch',
 
3709
        'bzrlib.tests.test_fixtures',
3704
3710
        'bzrlib.tests.test_fifo_cache',
3705
3711
        'bzrlib.tests.test_filters',
3706
3712
        'bzrlib.tests.test_ftp_transport',
3727
3733
        'bzrlib.tests.test_knit',
3728
3734
        'bzrlib.tests.test_lazy_import',
3729
3735
        'bzrlib.tests.test_lazy_regex',
 
3736
        'bzrlib.tests.test_library_state',
3730
3737
        'bzrlib.tests.test_lock',
3731
3738
        'bzrlib.tests.test_lockable_files',
3732
3739
        'bzrlib.tests.test_lockdir',
3836
3843
        'bzrlib.option',
3837
3844
        'bzrlib.symbol_versioning',
3838
3845
        'bzrlib.tests',
 
3846
        'bzrlib.tests.fixtures',
3839
3847
        'bzrlib.timestamp',
3840
3848
        'bzrlib.version_info_formats.format_custom',
3841
3849
        ]
4102
4110
        if test_id != None:
4103
4111
            ui.ui_factory.clear_term()
4104
4112
            sys.stderr.write('\nWhile running: %s\n' % (test_id,))
 
4113
        # Ugly, but the last thing we want here is fail, so bear with it.
 
4114
        printable_e = str(e).decode(osutils.get_user_encoding(), 'replace'
 
4115
                                    ).encode('ascii', 'replace')
4105
4116
        sys.stderr.write('Unable to remove testing dir %s\n%s'
4106
 
                         % (os.path.basename(dirname), e))
 
4117
                         % (os.path.basename(dirname), printable_e))
4107
4118
 
4108
4119
 
4109
4120
class Feature(object):
4339
4350
UnicodeFilename = _UnicodeFilename()
4340
4351
 
4341
4352
 
 
4353
class _ByteStringNamedFilesystem(Feature):
 
4354
    """Is the filesystem based on bytes?"""
 
4355
 
 
4356
    def _probe(self):
 
4357
        if os.name == "posix":
 
4358
            return True
 
4359
        return False
 
4360
 
 
4361
ByteStringNamedFilesystem = _ByteStringNamedFilesystem()
 
4362
 
 
4363
 
4342
4364
class _UTF8Filesystem(Feature):
4343
4365
    """Is the filesystem UTF-8?"""
4344
4366