~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Martin Pool
  • Date: 2006-03-07 08:22:37 UTC
  • mto: This revision was merged to the branch mainline in revision 1611.
  • Revision ID: mbp@sourcefrog.net-20060307082237-3e46d850858aec37
Construct unique test directory names even when test ids recurr

Show diffs side-by-side

added added

removed removed

Lines of Context:
591
591
        _currentdir = os.getcwdu()
592
592
        short_id = self.id().replace('bzrlib.tests.', '') \
593
593
                   .replace('__main__.', '')
594
 
        self.test_dir = osutils.pathjoin(self.TEST_ROOT, short_id)
595
 
        os.mkdir(self.test_dir)
596
 
        os.chdir(self.test_dir)
 
594
        # it's possible the same test class is run several times for
 
595
        # parameterized tests, so make sure the names don't collide.  
 
596
        i = 0
 
597
        while True:
 
598
            if i > 0:
 
599
                candidate_dir = '%s/%s.%d' % (self.TEST_ROOT, short_id, i)
 
600
            else:
 
601
                candidate_dir = '%s/%s' % (self.TEST_ROOT, short_id)
 
602
            if os.path.exists(candidate_dir):
 
603
                i = i + 1
 
604
                continue
 
605
            else:
 
606
                self.test_dir = candidate_dir
 
607
                os.mkdir(self.test_dir)
 
608
                os.chdir(self.test_dir)
 
609
                break
597
610
        os.environ['HOME'] = self.test_dir
598
611
        os.environ['APPDATA'] = self.test_dir
599
612
        def _leaveDirectory():