/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

Updated from dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
336
336
        self.assertEqual(mode, actual_mode,
337
337
            'mode of %r incorrect (%o != %o)' % (path, mode, actual_mode))
338
338
 
 
339
    def assertIsInstance(self, obj, kls):
 
340
        """Fail if obj is not an instance of kls"""
 
341
        if not isinstance(obj, kls):
 
342
            self.fail("%r is not an instance of %s" % (obj, kls))
 
343
 
339
344
    def _startLogFile(self):
340
345
        """Send bzr and test log messages to a temporary file.
341
346
 
600
605
        _currentdir = os.getcwdu()
601
606
        # shorten the name, to avoid test failures due to path length
602
607
        short_id = self.id().replace('bzrlib.tests.', '') \
603
 
                .replace('__main__.', '')[-100:]
604
 
        self.test_dir = osutils.pathjoin(self.TEST_ROOT, short_id)
605
 
        os.mkdir(self.test_dir)
606
 
        os.chdir(self.test_dir)
 
608
                   .replace('__main__.', '')[-100:]
 
609
        # it's possible the same test class is run several times for
 
610
        # parameterized tests, so make sure the names don't collide.  
 
611
        i = 0
 
612
        while True:
 
613
            if i > 0:
 
614
                candidate_dir = '%s/%s.%d' % (self.TEST_ROOT, short_id, i)
 
615
            else:
 
616
                candidate_dir = '%s/%s' % (self.TEST_ROOT, short_id)
 
617
            if os.path.exists(candidate_dir):
 
618
                i = i + 1
 
619
                continue
 
620
            else:
 
621
                self.test_dir = candidate_dir
 
622
                os.mkdir(self.test_dir)
 
623
                os.chdir(self.test_dir)
 
624
                break
607
625
        os.environ['HOME'] = self.test_dir
608
626
        os.environ['APPDATA'] = self.test_dir
609
627
        def _leaveDirectory():
862
880
    # This is still a little bogus, 
863
881
    # but only a little. Folk not using our testrunner will
864
882
    # have to delete their temp directories themselves.
 
883
    test_root = TestCaseInTempDir.TEST_ROOT
865
884
    if result.wasSuccessful() or not keep_output:
866
 
        if TestCaseInTempDir.TEST_ROOT is not None:
867
 
            shutil.rmtree(TestCaseInTempDir.TEST_ROOT) 
 
885
        if test_root is not None:
 
886
            print 'Deleting test root %s...' % test_root
 
887
            try:
 
888
                shutil.rmtree(test_root)
 
889
            finally:
 
890
                print
868
891
    else:
869
892
        print "Failed tests working directories are in '%s'\n" % TestCaseInTempDir.TEST_ROOT
870
893
    return result.wasSuccessful()