~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_selftest.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-05-11 17:50:37 UTC
  • mfrom: (1704.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060511175037-f66b84c6a9fc4c12
Merge selftest uses progress-bars. (Robert Collins).

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
"""UI tests for the test framework."""
17
17
 
 
18
import sys
 
19
 
18
20
import bzrlib
19
21
from bzrlib.errors import ParamikoNotPresent
20
22
from bzrlib.tests import (
99
101
                         a_callable=None, *args, **kwargs):
100
102
        self.stdin = stdin
101
103
        self.factory_stdin = getattr(bzrlib.ui.ui_factory, "stdin", None)
 
104
        self.factory = bzrlib.ui.ui_factory
 
105
        stdout.write('foo\n')
 
106
        stderr.write('bar\n')
102
107
        return 0
103
108
 
104
109
    def test_stdin(self):
112
117
        self.run_bzr_captured(['foo', 'bar'], stdin='zippy')
113
118
        self.assertEqual('zippy', self.stdin.read())
114
119
        self.assertTrue(self.stdin is self.factory_stdin)
 
120
 
 
121
    def test_ui_factory(self):
 
122
        # each invocation of self.run_bzr_captured should get its own UI
 
123
        # factory, which is an instance of TestUIFactory, with stdout and
 
124
        # stderr attached to the stdout and stderr of the invoked
 
125
        # run_bzr_captured
 
126
        current_factory = bzrlib.ui.ui_factory
 
127
        self.run_bzr_captured(['foo'])
 
128
        self.failIf(current_factory is self.factory)
 
129
        self.assertNotEqual(sys.stdout, self.factory.stdout)
 
130
        self.assertNotEqual(sys.stderr, self.factory.stderr)
 
131
        self.assertEqual('foo\n', self.factory.stdout.getvalue())
 
132
        self.assertEqual('bar\n', self.factory.stderr.getvalue())
 
133
        self.assertIsInstance(self.factory, bzrlib.tests.blackbox.TestUIFactory)