~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Patch Queue Manager
  • Date: 2012-08-23 14:24:38 UTC
  • mfrom: (6499.3.13 832042-shared-stores)
  • Revision ID: pqm@pqm.ubuntu.com-20120823142438-804xd3yql622ahhp
(vila) Share and cache local config files (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1001
1001
    def setUp(self):
1002
1002
        super(TestCase, self).setUp()
1003
1003
 
 
1004
        # At this point we're still accessing the config files in $BZR_HOME (as
 
1005
        # set by the user running selftest).
1004
1006
        timeout = config.GlobalStack().get('selftest.timeout')
1005
1007
        if timeout:
1006
1008
            timeout_fixture = fixtures.TimeoutFixture(timeout)
2447
2449
        self.transport_readonly_server = None
2448
2450
        self.__vfs_server = None
2449
2451
 
 
2452
    def setUp(self):
 
2453
        super(TestCaseWithMemoryTransport, self).setUp()
 
2454
 
 
2455
        def _add_disconnect_cleanup(transport):
 
2456
            """Schedule disconnection of given transport at test cleanup
 
2457
 
 
2458
            This needs to happen for all connected transports or leaks occur.
 
2459
 
 
2460
            Note reconnections may mean we call disconnect multiple times per
 
2461
            transport which is suboptimal but seems harmless.
 
2462
            """
 
2463
            self.addCleanup(transport.disconnect)
 
2464
 
 
2465
        _mod_transport.Transport.hooks.install_named_hook('post_connect',
 
2466
            _add_disconnect_cleanup, None)
 
2467
 
 
2468
        self._make_test_root()
 
2469
        self.addCleanup(os.chdir, os.getcwdu())
 
2470
        self.makeAndChdirToTestDir()
 
2471
        self.overrideEnvironmentForTesting()
 
2472
        self.__readonly_server = None
 
2473
        self.__server = None
 
2474
        self.reduceLockdirTimeout()
 
2475
        # Each test may use its own config files even if the local config files
 
2476
        # don't actually exist. They'll rightly fail if they try to create them
 
2477
        # though.
 
2478
        self.overrideAttr(config, '_shared_stores', {})
 
2479
 
2450
2480
    def get_transport(self, relpath=None):
2451
2481
        """Return a writeable transport.
2452
2482
 
2733
2763
        self.overrideEnv('HOME', test_home_dir)
2734
2764
        self.overrideEnv('BZR_HOME', test_home_dir)
2735
2765
 
2736
 
    def setUp(self):
2737
 
        super(TestCaseWithMemoryTransport, self).setUp()
2738
 
 
2739
 
        def _add_disconnect_cleanup(transport):
2740
 
            """Schedule disconnection of given transport at test cleanup
2741
 
 
2742
 
            This needs to happen for all connected transports or leaks occur.
2743
 
 
2744
 
            Note reconnections may mean we call disconnect multiple times per
2745
 
            transport which is suboptimal but seems harmless.
2746
 
            """
2747
 
            self.addCleanup(transport.disconnect)
2748
 
 
2749
 
        _mod_transport.Transport.hooks.install_named_hook('post_connect',
2750
 
            _add_disconnect_cleanup, None)
2751
 
 
2752
 
        self._make_test_root()
2753
 
        self.addCleanup(os.chdir, os.getcwdu())
2754
 
        self.makeAndChdirToTestDir()
2755
 
        self.overrideEnvironmentForTesting()
2756
 
        self.__readonly_server = None
2757
 
        self.__server = None
2758
 
        self.reduceLockdirTimeout()
2759
 
 
2760
2766
    def setup_smart_server_with_call_log(self):
2761
2767
        """Sets up a smart server as the transport server with a call log."""
2762
2768
        self.transport_server = test_server.SmartTCPServer_for_testing
2949
2955
    readwrite one must both define get_url() as resolving to os.getcwd().
2950
2956
    """
2951
2957
 
 
2958
    def setUp(self):
 
2959
        super(TestCaseWithTransport, self).setUp()
 
2960
        self.__vfs_server = None
 
2961
 
2952
2962
    def get_vfs_only_server(self):
2953
2963
        """See TestCaseWithMemoryTransport.
2954
2964
 
3037
3047
        self.assertFalse(differences.has_changed(),
3038
3048
            "Trees %r and %r are different: %r" % (left, right, differences))
3039
3049
 
3040
 
    def setUp(self):
3041
 
        super(TestCaseWithTransport, self).setUp()
3042
 
        self.__vfs_server = None
3043
 
 
3044
3050
    def disable_missing_extensions_warning(self):
3045
3051
        """Some tests expect a precise stderr content.
3046
3052
 
3047
3053
        There is no point in forcing them to duplicate the extension related
3048
3054
        warning.
3049
3055
        """
3050
 
        config.GlobalConfig().set_user_option('ignore_missing_extensions', True)
 
3056
        config.GlobalStack().set('ignore_missing_extensions', True)
3051
3057
 
3052
3058
 
3053
3059
class ChrootedTestCase(TestCaseWithTransport):