~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/__init__.py

[merge] from robert and fix up tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
169
169
 
170
170
    def setUp(self):
171
171
        unittest.TestCase.setUp(self)
 
172
        self.oldenv = os.environ.get('HOME', None)
 
173
        os.environ['HOME'] = os.getcwd()
 
174
        self.bzr_email = os.environ.get('BZREMAIL')
 
175
        if self.bzr_email is not None:
 
176
            del os.environ['BZREMAIL']
 
177
        self.email = os.environ.get('EMAIL')
 
178
        if self.email is not None:
 
179
            del os.environ['EMAIL']
172
180
        bzrlib.trace.disable_default_logging()
173
181
        self._enable_file_logging()
174
182
 
221
229
        self._log_file_name = name
222
230
 
223
231
    def tearDown(self):
 
232
        os.environ['HOME'] = self.oldenv
 
233
        if os.environ.get('BZREMAIL') is not None:
 
234
            del os.environ['BZREMAIL']
 
235
        if self.bzr_email is not None:
 
236
            os.environ['BZREMAIL'] = self.bzr_email
 
237
        if os.environ.get('EMAIL') is not None:
 
238
            del os.environ['EMAIL']
 
239
        if self.email is not None:
 
240
            os.environ['EMAIL'] = self.email
224
241
        logging.getLogger('').removeHandler(self._log_hdlr)
225
242
        bzrlib.trace.enable_default_logging()
226
243
        logging.debug('%s teardown', self.id())
401
418
        os.mkdir(os.path.join(TestCaseInTempDir.TEST_ROOT, '.bzr'))
402
419
 
403
420
    def setUp(self):
404
 
        super(TestCaseInTempDir, self).setUp()
405
421
        self._make_test_root()
406
422
        self._currentdir = os.getcwdu()
407
423
        short_id = self.id().replace('bzrlib.selftest.', '') \
409
425
        self.test_dir = os.path.join(self.TEST_ROOT, short_id)
410
426
        os.mkdir(self.test_dir)
411
427
        os.chdir(self.test_dir)
 
428
        super(TestCaseInTempDir, self).setUp()
412
429
        
413
430
    def tearDown(self):
414
431
        os.chdir(self._currentdir)
499
516
 
500
517
    testmod_names = \
501
518
                  ['bzrlib.selftest.MetaTestLog',
 
519
                   'bzrlib.selftest.testgpg',
502
520
                   'bzrlib.selftest.testidentitymap',
503
521
                   'bzrlib.selftest.testinv',
504
522
                   'bzrlib.selftest.test_ancestry',