~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

Merge bzr.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
        short_id = self.id().replace('bzrlib.tests.', '') \
602
607
                   .replace('__main__.', '')
603
 
        self.test_dir = osutils.pathjoin(self.TEST_ROOT, short_id)
604
 
        os.mkdir(self.test_dir)
605
 
        os.chdir(self.test_dir)
 
608
        # it's possible the same test class is run several times for
 
609
        # parameterized tests, so make sure the names don't collide.  
 
610
        i = 0
 
611
        while True:
 
612
            if i > 0:
 
613
                candidate_dir = '%s/%s.%d' % (self.TEST_ROOT, short_id, i)
 
614
            else:
 
615
                candidate_dir = '%s/%s' % (self.TEST_ROOT, short_id)
 
616
            if os.path.exists(candidate_dir):
 
617
                i = i + 1
 
618
                continue
 
619
            else:
 
620
                self.test_dir = candidate_dir
 
621
                os.mkdir(self.test_dir)
 
622
                os.chdir(self.test_dir)
 
623
                break
606
624
        os.environ['HOME'] = self.test_dir
607
625
        os.environ['APPDATA'] = self.test_dir
608
626
        def _leaveDirectory():