/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Wouter van Heyst
  • Date: 2006-06-06 12:06:20 UTC
  • mfrom: (1740 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: larstiq@larstiq.dyndns.org-20060606120620-50066b0951e4ef7c
merge bzr.dev 1740

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 (
75
77
            TestOptions.current_test = None
76
78
            TestCaseInTempDir.TEST_ROOT = old_root
77
79
 
 
80
    def test_benchmark_runs_benchmark_tests(self):
 
81
        """bzr selftest --benchmark should not run the default test suite."""
 
82
        # We test this by passing a regression test name to --benchmark, which
 
83
        # should result in 0 rests run.
 
84
        out, err = self.run_bzr('selftest', '--benchmark', 'workingtree_implementations')
 
85
        self.assertContainsRe(out, 'Ran 0 tests.*\n\nOK')
 
86
        self.assertEqual(
 
87
            'running tests...\ntests passed\n',
 
88
            err)
 
89
        
78
90
 
79
91
class TestRunBzr(ExternalBase):
80
92
 
99
111
                         a_callable=None, *args, **kwargs):
100
112
        self.stdin = stdin
101
113
        self.factory_stdin = getattr(bzrlib.ui.ui_factory, "stdin", None)
 
114
        self.factory = bzrlib.ui.ui_factory
 
115
        stdout.write('foo\n')
 
116
        stderr.write('bar\n')
102
117
        return 0
103
118
 
104
119
    def test_stdin(self):
112
127
        self.run_bzr_captured(['foo', 'bar'], stdin='zippy')
113
128
        self.assertEqual('zippy', self.stdin.read())
114
129
        self.assertTrue(self.stdin is self.factory_stdin)
 
130
 
 
131
    def test_ui_factory(self):
 
132
        # each invocation of self.run_bzr_captured should get its own UI
 
133
        # factory, which is an instance of TestUIFactory, with stdout and
 
134
        # stderr attached to the stdout and stderr of the invoked
 
135
        # run_bzr_captured
 
136
        current_factory = bzrlib.ui.ui_factory
 
137
        self.run_bzr_captured(['foo'])
 
138
        self.failIf(current_factory is self.factory)
 
139
        self.assertNotEqual(sys.stdout, self.factory.stdout)
 
140
        self.assertNotEqual(sys.stderr, self.factory.stderr)
 
141
        self.assertEqual('foo\n', self.factory.stdout.getvalue())
 
142
        self.assertEqual('bar\n', self.factory.stderr.getvalue())
 
143
        self.assertIsInstance(self.factory, bzrlib.tests.blackbox.TestUIFactory)