~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Martin Pool
  • Date: 2007-05-13 07:25:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2530.
  • Revision ID: mbp@sourcefrog.net-20070513072544-nqoezox04fjhtf1o
Move unicode handling code into _rmtree_temp_dir

Show diffs side-by-side

added added

removed removed

Lines of Context:
581
581
        test_root = TestCaseWithMemoryTransport.TEST_ROOT
582
582
        if result.wasSuccessful() or not self.keep_output:
583
583
            if test_root is not None:
584
 
                # If LANG=C we probably have created some bogus paths
585
 
                # which rmtree(unicode) will fail to delete
586
 
                # so make sure we are using rmtree(str) to delete everything
587
 
                # except on win32, where rmtree(str) will fail
588
 
                # since it doesn't have the property of byte-stream paths
589
 
                # (they are either ascii or mbcs)
590
 
                if sys.platform == 'win32':
591
 
                    # make sure we are using the unicode win32 api
592
 
                    test_root = unicode(test_root)
593
 
                else:
594
 
                    test_root = test_root.encode(
595
 
                        sys.getfilesystemencoding())
596
584
                _rmtree_temp_dir(test_root)
597
585
        else:
598
586
            note("Failed tests working directories are in '%s'\n", test_root)
2427
2415
 
2428
2416
 
2429
2417
def _rmtree_temp_dir(dirname):
 
2418
    # If LANG=C we probably have created some bogus paths
 
2419
    # which rmtree(unicode) will fail to delete
 
2420
    # so make sure we are using rmtree(str) to delete everything
 
2421
    # except on win32, where rmtree(str) will fail
 
2422
    # since it doesn't have the property of byte-stream paths
 
2423
    # (they are either ascii or mbcs)
 
2424
    if sys.platform == 'win32':
 
2425
        # make sure we are using the unicode win32 api
 
2426
        dirname = unicode(dirname)
 
2427
    else:
 
2428
        dirname = dirname.encode(sys.getfilesystemencoding())
2430
2429
    try:
2431
2430
        osutils.rmtree(dirname)
2432
2431
    except OSError, e: