~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

Get run_bzr in tests to always assign a new, clean ui factory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
474
474
        handler.setLevel(logging.INFO)
475
475
        logger = logging.getLogger('')
476
476
        logger.addHandler(handler)
477
 
        old_stdin = getattr(bzrlib.ui.ui_factory, "stdin", None)
 
477
        old_ui_factory = bzrlib.ui.ui_factory
 
478
        bzrlib.ui.ui_factory = bzrlib.tests.blackbox.TestUIFactory(
 
479
            stdout=stdout,
 
480
            stderr=stderr)
478
481
        bzrlib.ui.ui_factory.stdin = stdin
479
482
        try:
480
483
            result = self.apply_redirected(stdin, stdout, stderr,
482
485
                                           argv)
483
486
        finally:
484
487
            logger.removeHandler(handler)
485
 
            bzrlib.ui.ui_factory.stdin = old_stdin
 
488
            bzrlib.ui.ui_factory = old_ui_factory
486
489
        out = stdout.getvalue()
487
490
        err = stderr.getvalue()
488
491
        if out: