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

  • Committer: John Arbash Meinel
  • Date: 2006-10-31 21:29:02 UTC
  • mfrom: (2104 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2110.
  • Revision ID: john@arbash-meinel.com-20061031212902-4b33920b90e9ce92
[merge] bzr.dev 2104

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 by Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License version 2 as published by
5
 
# the Free Software Foundation.
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
6
7
#
7
8
# This program is distributed in the hope that it will be useful,
8
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
23
24
import unittest
24
25
import warnings
25
26
 
26
 
from bzrlib import osutils
27
27
import bzrlib
 
28
from bzrlib import (
 
29
    bzrdir,
 
30
    memorytree,
 
31
    osutils,
 
32
    repository,
 
33
    )
28
34
from bzrlib.progress import _BaseProgressBar
29
35
from bzrlib.tests import (
30
36
                          ChrootedTestCase,
31
37
                          TestCase,
32
38
                          TestCaseInTempDir,
 
39
                          TestCaseWithMemoryTransport,
33
40
                          TestCaseWithTransport,
34
41
                          TestSkipped,
35
42
                          TestSuite,
434
441
        self.assertEqual(self.test_home_dir, os.environ['HOME'])
435
442
 
436
443
 
 
444
class TestTestCaseWithMemoryTransport(TestCaseWithMemoryTransport):
 
445
 
 
446
    def test_home_is_non_existant_dir_under_root(self):
 
447
        """The test_home_dir for TestCaseWithMemoryTransport is missing.
 
448
 
 
449
        This is because TestCaseWithMemoryTransport is for tests that do not
 
450
        need any disk resources: they should be hooked into bzrlib in such a 
 
451
        way that no global settings are being changed by the test (only a 
 
452
        few tests should need to do that), and having a missing dir as home is
 
453
        an effective way to ensure that this is the case.
 
454
        """
 
455
        self.assertEqual(self.TEST_ROOT + "/MemoryTransportMissingHomeDir",
 
456
            self.test_home_dir)
 
457
        self.assertEqual(self.test_home_dir, os.environ['HOME'])
 
458
        
 
459
    def test_cwd_is_TEST_ROOT(self):
 
460
        self.assertEqual(self.test_dir, self.TEST_ROOT)
 
461
        cwd = osutils.getcwd()
 
462
        self.assertEqual(self.test_dir, cwd)
 
463
 
 
464
    def test_make_branch_and_memory_tree(self):
 
465
        """In TestCaseWithMemoryTransport we should not make the branch on disk.
 
466
 
 
467
        This is hard to comprehensively robustly test, so we settle for making
 
468
        a branch and checking no directory was created at its relpath.
 
469
        """
 
470
        tree = self.make_branch_and_memory_tree('dir')
 
471
        self.failIfExists('dir')
 
472
        self.assertIsInstance(tree, memorytree.MemoryTree)
 
473
 
 
474
    def test_make_branch_and_memory_tree_with_format(self):
 
475
        """make_branch_and_memory_tree should accept a format option."""
 
476
        format = bzrdir.BzrDirMetaFormat1()
 
477
        format.repository_format = repository.RepositoryFormat7()
 
478
        tree = self.make_branch_and_memory_tree('dir', format=format)
 
479
        self.failIfExists('dir')
 
480
        self.assertIsInstance(tree, memorytree.MemoryTree)
 
481
        self.assertEqual(format.repository_format.__class__,
 
482
            tree.branch.repository._format.__class__)
 
483
 
 
484
 
437
485
class TestTestCaseWithTransport(TestCaseWithTransport):
438
486
    """Tests for the convenience functions TestCaseWithTransport introduces."""
439
487
 
455
503
 
456
504
    def test_get_readonly_url_http(self):
457
505
        from bzrlib.transport import get_transport
458
 
        from bzrlib.transport.local import LocalRelpathServer
 
506
        from bzrlib.transport.local import LocalURLServer
459
507
        from bzrlib.transport.http import HttpServer, HttpTransportBase
460
 
        self.transport_server = LocalRelpathServer
 
508
        self.transport_server = LocalURLServer
461
509
        self.transport_readonly_server = HttpServer
462
510
        # calling get_readonly_transport() gives us a HTTP server instance.
463
511
        url = self.get_readonly_url()
984
1032
        self.assertIsInstance(bzrlib.bzrdir.BzrDir.open('b')._format,
985
1033
                              bzrlib.bzrdir.BzrDirFormat6)
986
1034
 
987
 
    def test_make_branch_and_mutable_tree(self):
 
1035
    def test_make_branch_and_memory_tree(self):
988
1036
        # we should be able to get a new branch and a mutable tree from
989
1037
        # TestCaseWithTransport
990
1038
        tree = self.make_branch_and_memory_tree('a')