251
261
self._cleanups.append(callable)
253
263
def _cleanEnvironment(self):
254
self.oldenv = os.environ.get('HOME', None)
255
os.environ['HOME'] = os.getcwd()
256
self.bzr_email = os.environ.get('BZREMAIL')
257
if self.bzr_email is not None:
258
del os.environ['BZREMAIL']
259
self.email = os.environ.get('EMAIL')
260
if self.email is not None:
261
del os.environ['EMAIL']
266
'APPDATA': os.getcwd(),
262
271
self.addCleanup(self._restoreEnvironment)
272
for name, value in new_env.iteritems():
273
self._captureVar(name, value)
276
def _captureVar(self, name, newvalue):
277
"""Set an environment variable, preparing it to be reset when finished."""
278
self.__old_env[name] = os.environ.get(name, None)
280
if name in os.environ:
283
os.environ[name] = newvalue
286
def _restoreVar(name, value):
288
if name in os.environ:
291
os.environ[name] = value
264
293
def _restoreEnvironment(self):
265
os.environ['HOME'] = self.oldenv
266
if os.environ.get('BZREMAIL') is not None:
267
del os.environ['BZREMAIL']
268
if self.bzr_email is not None:
269
os.environ['BZREMAIL'] = self.bzr_email
270
if os.environ.get('EMAIL') is not None:
271
del os.environ['EMAIL']
272
if self.email is not None:
273
os.environ['EMAIL'] = self.email
294
for name, value in self.__old_env.iteritems():
295
self._restoreVar(name, value)
275
297
def tearDown(self):
276
298
self._runCleanups()
562
596
# exception is hidden by unittest. Sucks. Should either fix that or
563
597
# perhaps import them and pass them to unittest as modules.
564
598
testmod_names = \
565
['bzrlib.selftest.MetaTestLog',
566
'bzrlib.selftest.testapi',
567
'bzrlib.selftest.testgpg',
568
'bzrlib.selftest.testidentitymap',
569
'bzrlib.selftest.testinv',
570
'bzrlib.selftest.test_ancestry',
571
'bzrlib.selftest.test_commit',
572
'bzrlib.selftest.test_command',
573
'bzrlib.selftest.test_commit_merge',
574
'bzrlib.selftest.testconfig',
575
'bzrlib.selftest.testmerge3',
576
'bzrlib.selftest.testmerge',
577
'bzrlib.selftest.testhashcache',
578
'bzrlib.selftest.teststatus',
579
'bzrlib.selftest.testlog',
580
'bzrlib.selftest.testrevisionnamespaces',
581
'bzrlib.selftest.testbranch',
582
'bzrlib.selftest.testrevision',
583
'bzrlib.selftest.test_revision_info',
584
'bzrlib.selftest.test_merge_core',
585
'bzrlib.selftest.test_smart_add',
586
'bzrlib.selftest.test_bad_files',
587
'bzrlib.selftest.testdiff',
588
'bzrlib.selftest.test_parent',
589
'bzrlib.selftest.test_xml',
590
'bzrlib.selftest.test_weave',
591
'bzrlib.selftest.testfetch',
592
'bzrlib.selftest.whitebox',
593
'bzrlib.selftest.teststore',
594
'bzrlib.selftest.blackbox',
595
'bzrlib.selftest.blackbox.test_bound_branches',
596
'bzrlib.selftest.blackbox.versioning',
597
'bzrlib.selftest.testsampler',
598
'bzrlib.selftest.testtransactions',
599
'bzrlib.selftest.testtransport',
600
'bzrlib.selftest.testsftp',
601
'bzrlib.selftest.testgraph',
602
'bzrlib.selftest.testworkingtree',
603
'bzrlib.selftest.test_upgrade',
604
'bzrlib.selftest.test_conflicts',
605
'bzrlib.selftest.testtestament',
606
'bzrlib.selftest.testannotate',
607
'bzrlib.selftest.testrevprops',
608
'bzrlib.selftest.testoptions',
609
'bzrlib.selftest.testhttp',
610
'bzrlib.selftest.testnonascii',
611
'bzrlib.selftest.testreweave',
612
'bzrlib.selftest.testtsort',
613
'bzrlib.selftest.testtrace',
599
['bzrlib.tests.MetaTestLog',
600
'bzrlib.tests.test_api',
601
'bzrlib.tests.test_gpg',
602
'bzrlib.tests.test_identitymap',
603
'bzrlib.tests.test_inv',
604
'bzrlib.tests.test_ancestry',
605
'bzrlib.tests.test_commit',
606
'bzrlib.tests.test_command',
607
'bzrlib.tests.test_commit_merge',
608
'bzrlib.tests.test_config',
609
'bzrlib.tests.test_merge3',
610
'bzrlib.tests.test_merge',
611
'bzrlib.tests.test_hashcache',
612
'bzrlib.tests.test_status',
613
'bzrlib.tests.test_log',
614
'bzrlib.tests.test_revisionnamespaces',
615
'bzrlib.tests.test_branch',
616
'bzrlib.tests.test_revision',
617
'bzrlib.tests.test_revision_info',
618
'bzrlib.tests.test_merge_core',
619
'bzrlib.tests.test_smart_add',
620
'bzrlib.tests.test_bad_files',
621
'bzrlib.tests.test_diff',
622
'bzrlib.tests.test_parent',
623
'bzrlib.tests.test_xml',
624
'bzrlib.tests.test_weave',
625
'bzrlib.tests.test_fetch',
626
'bzrlib.tests.test_whitebox',
627
'bzrlib.tests.test_store',
628
'bzrlib.tests.blackbox',
629
'bzrlib.tests.blackbox.versioning',
630
'bzrlib.tests.blackbox.test_bound_branch',
631
'bzrlib.tests.test_sampler',
632
'bzrlib.tests.test_transactions',
633
'bzrlib.tests.test_transport',
634
'bzrlib.tests.test_sftp',
635
'bzrlib.tests.test_graph',
636
'bzrlib.tests.test_workingtree',
637
'bzrlib.tests.test_upgrade',
638
'bzrlib.tests.test_uncommit',
639
'bzrlib.tests.test_conflicts',
640
'bzrlib.tests.test_testament',
641
'bzrlib.tests.test_annotate',
642
'bzrlib.tests.test_revprops',
643
'bzrlib.tests.test_options',
644
'bzrlib.tests.test_http',
645
'bzrlib.tests.test_nonascii',
646
'bzrlib.tests.test_reweave',
647
'bzrlib.tests.test_tsort',
648
'bzrlib.tests.test_trace',
649
'bzrlib.tests.test_basicio',
616
652
for m in (bzrlib.store, bzrlib.inventory, bzrlib.branch,