~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/__init__.py

merge up with martin I hope... default merge base told me I was adding builtins.py ..

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import tempfile
21
21
import os
22
22
import sys
 
23
import errno
23
24
import subprocess
 
25
import shutil
24
26
 
25
 
from testsweet import run_suite
 
27
import testsweet
26
28
import bzrlib.commands
27
29
 
28
30
import bzrlib.trace
188
190
            self.fail("contents of %s not as expected")
189
191
 
190
192
    def _make_test_root(self):
191
 
        import os
192
 
        import shutil
193
 
        import tempfile
194
 
        
195
193
        if TestCaseInTempDir.TEST_ROOT is not None:
196
194
            return
197
 
        TestCaseInTempDir.TEST_ROOT = os.path.abspath(
198
 
                                 tempfile.mkdtemp(suffix='.tmp',
199
 
                                                  prefix=self._TEST_NAME + '-',
200
 
                                                  dir=os.curdir))
201
 
    
 
195
        i = 0
 
196
        while True:
 
197
            root = 'test%04d.tmp' % i
 
198
            try:
 
199
                os.mkdir(root)
 
200
            except OSError, e:
 
201
                if e.errno == errno.EEXIST:
 
202
                    i += 1
 
203
                    continue
 
204
                else:
 
205
                    raise
 
206
            # successfully created
 
207
            TestCaseInTempDir.TEST_ROOT = os.path.abspath(root)
 
208
            break
202
209
        # make a fake bzr directory there to prevent any tests propagating
203
210
        # up onto the source directory's real branch
204
211
        os.mkdir(os.path.join(TestCaseInTempDir.TEST_ROOT, '.bzr'))
292
299
 
293
300
 
294
301
def selftest(verbose=False, pattern=".*"):
295
 
    return run_suite(test_suite(), 'testbzr', verbose=verbose, pattern=pattern)
 
302
    return testsweet.run_suite(test_suite(), 'testbzr', verbose=verbose, pattern=pattern)
296
303
 
297
304
 
298
305
def test_suite():