~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Vincent Ladeuil
  • Date: 2012-08-03 11:23:55 UTC
  • mto: This revision was merged to the branch mainline in revision 6554.
  • Revision ID: v.ladeuil+lp@free.fr-20120803112355-3fh78wck6i12vv1h
Provide fresh config stores for tests.

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
 
2730
2760
        self.overrideEnv('HOME', test_home_dir)
2731
2761
        self.overrideEnv('BZR_HOME', test_home_dir)
2732
2762
 
2733
 
    def setUp(self):
2734
 
        super(TestCaseWithMemoryTransport, self).setUp()
2735
 
 
2736
 
        def _add_disconnect_cleanup(transport):
2737
 
            """Schedule disconnection of given transport at test cleanup
2738
 
 
2739
 
            This needs to happen for all connected transports or leaks occur.
2740
 
 
2741
 
            Note reconnections may mean we call disconnect multiple times per
2742
 
            transport which is suboptimal but seems harmless.
2743
 
            """
2744
 
            self.addCleanup(transport.disconnect)
2745
 
 
2746
 
        _mod_transport.Transport.hooks.install_named_hook('post_connect',
2747
 
            _add_disconnect_cleanup, None)
2748
 
 
2749
 
        self._make_test_root()
2750
 
        self.addCleanup(os.chdir, os.getcwdu())
2751
 
        self.makeAndChdirToTestDir()
2752
 
        self.overrideEnvironmentForTesting()
2753
 
        self.__readonly_server = None
2754
 
        self.__server = None
2755
 
        self.reduceLockdirTimeout()
2756
 
 
2757
2763
    def setup_smart_server_with_call_log(self):
2758
2764
        """Sets up a smart server as the transport server with a call log."""
2759
2765
        self.transport_server = test_server.SmartTCPServer_for_testing
2946
2952
    readwrite one must both define get_url() as resolving to os.getcwd().
2947
2953
    """
2948
2954
 
 
2955
    def setUp(self):
 
2956
        super(TestCaseWithTransport, self).setUp()
 
2957
        self.__vfs_server = None
 
2958
 
2949
2959
    def get_vfs_only_server(self):
2950
2960
        """See TestCaseWithMemoryTransport.
2951
2961
 
3034
3044
        self.assertFalse(differences.has_changed(),
3035
3045
            "Trees %r and %r are different: %r" % (left, right, differences))
3036
3046
 
3037
 
    def setUp(self):
3038
 
        super(TestCaseWithTransport, self).setUp()
3039
 
        self.__vfs_server = None
3040
 
 
3041
3047
    def disable_missing_extensions_warning(self):
3042
3048
        """Some tests expect a precise stderr content.
3043
3049