~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2005-10-19 09:34:39 UTC
  • mfrom: (1185.16.78)
  • mto: (1185.16.102)
  • mto: This revision was merged to the branch mainline in revision 1488.
  • Revision ID: jelmer@samba.org-20051019093439-e1d8e3508d1ba46b
MergeĀ fromĀ Martin

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
 
175
183
    def _ndiff_strings(self, a, b):
176
 
        """Return ndiff between two strings containing lines."""
 
184
        """Return ndiff between two strings containing lines.
 
185
        
 
186
        A trailing newline is added if missing to make the strings
 
187
        print properly."""
 
188
        if b and b[-1] != '\n':
 
189
            b += '\n'
 
190
        if a and a[-1] != '\n':
 
191
            a += '\n'
177
192
        difflines = difflib.ndiff(a.splitlines(True),
178
193
                                  b.splitlines(True),
179
194
                                  linejunk=lambda x: False,
214
229
        self._log_file_name = name
215
230
 
216
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
217
241
        logging.getLogger('').removeHandler(self._log_hdlr)
218
242
        bzrlib.trace.enable_default_logging()
219
243
        logging.debug('%s teardown', self.id())
394
418
        os.mkdir(os.path.join(TestCaseInTempDir.TEST_ROOT, '.bzr'))
395
419
 
396
420
    def setUp(self):
397
 
        super(TestCaseInTempDir, self).setUp()
398
421
        self._make_test_root()
399
422
        self._currentdir = os.getcwdu()
400
423
        short_id = self.id().replace('bzrlib.selftest.', '') \
402
425
        self.test_dir = os.path.join(self.TEST_ROOT, short_id)
403
426
        os.mkdir(self.test_dir)
404
427
        os.chdir(self.test_dir)
 
428
        super(TestCaseInTempDir, self).setUp()
405
429
        
406
430
    def tearDown(self):
407
431
        os.chdir(self._currentdir)
492
516
 
493
517
    testmod_names = \
494
518
                  ['bzrlib.selftest.MetaTestLog',
 
519
                   'bzrlib.selftest.testgpg',
495
520
                   'bzrlib.selftest.testidentitymap',
496
521
                   'bzrlib.selftest.testinv',
497
522
                   'bzrlib.selftest.test_ancestry',
530
555
                   'bzrlib.selftest.testannotate',
531
556
                   'bzrlib.selftest.testrevprops',
532
557
                   'bzrlib.selftest.testoptions',
 
558
                   'bzrlib.selftest.testhttp',
 
559
                   'bzrlib.selftest.testnonascii',
533
560
                   ]
534
561
 
535
562
    for m in (bzrlib.store, bzrlib.inventory, bzrlib.branch,
536
 
              bzrlib.osutils, bzrlib.commands, bzrlib.merge3):
 
563
              bzrlib.osutils, bzrlib.commands, bzrlib.merge3,
 
564
              bzrlib.errors,
 
565
              ):
537
566
        if m not in MODULES_TO_DOCTEST:
538
567
            MODULES_TO_DOCTEST.append(m)
539
568