~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""UI tests for the test framework."""
18
18
 
 
19
from cStringIO import StringIO
19
20
import os
20
21
import re
21
22
import signal
22
23
import sys
 
24
import unittest
23
25
 
24
26
import bzrlib
25
27
from bzrlib import (
27
29
    )
28
30
from bzrlib.errors import ParamikoNotPresent
29
31
from bzrlib.tests import (
 
32
                          SubUnitFeature,
30
33
                          TestCase,
31
34
                          TestCaseInTempDir,
32
35
                          TestCaseWithMemoryTransport,
88
91
            TestOptions.current_test = None
89
92
            TestCaseWithMemoryTransport.TEST_ROOT = old_root
90
93
 
 
94
    def test_subunit(self):
 
95
        """Passing --subunit results in subunit output."""
 
96
        self.requireFeature(SubUnitFeature)
 
97
        from subunit import ProtocolTestCase
 
98
        stdout = self.run_bzr(
 
99
            'selftest --subunit --no-plugins '
 
100
            'tests.test_selftest.SelftestTests.test_import_tests')[0]
 
101
        stream = StringIO(str(stdout))
 
102
        test = ProtocolTestCase(stream)
 
103
        result = unittest.TestResult()
 
104
        test.run(result)
 
105
        # 1 to deal with the 'test:' noise at the start, and 1 for the one we
 
106
        # ran.
 
107
        self.assertEqual(2, result.testsRun)
 
108
 
91
109
 
92
110
class TestRunBzr(ExternalBase):
93
111
 
141
159
        # test that the stdin keyword to run_bzr is passed through to
142
160
        # _run_bzr_core as-is. We do this by overriding
143
161
        # _run_bzr_core in this class, and then calling run_bzr,
144
 
        # which is a convenience function for _run_bzr_core, so 
 
162
        # which is a convenience function for _run_bzr_core, so
145
163
        # should invoke it.
146
164
        self.run_bzr('foo bar', stdin='gam')
147
165
        self.assertEqual('gam', self.stdin)
208
226
        # test that the stdin keyword to _run_bzr_core is passed through to
209
227
        # apply_redirected as a StringIO. We do this by overriding
210
228
        # apply_redirected in this class, and then calling _run_bzr_core,
211
 
        # which calls apply_redirected. 
 
229
        # which calls apply_redirected.
212
230
        self.run_bzr(['foo', 'bar'], stdin='gam')
213
231
        self.assertEqual('gam', self.stdin.read())
214
232
        self.assertTrue(self.stdin is self.factory_stdin)
262
280
        result = self.run_bzr_subprocess(['--version'])
263
281
        result = self.run_bzr_subprocess('--version', retcode=None)
264
282
        self.assertContainsRe(result[0], 'is free software')
265
 
        self.assertRaises(AssertionError, self.run_bzr_subprocess, 
 
283
        self.assertRaises(AssertionError, self.run_bzr_subprocess,
266
284
                          '--versionn')
267
285
        result = self.run_bzr_subprocess('--versionn', retcode=3)
268
286
        result = self.run_bzr_subprocess('--versionn', retcode=None)
428
446
        process = self.start_bzr_subprocess(['--versionn'])
429
447
        self.assertRaises(self.failureException, self.finish_bzr_subprocess,
430
448
                          process)
431
 
        
 
449
 
432
450
    def test_start_and_stop_bzr_subprocess_send_signal(self):
433
451
        """finish_bzr_subprocess raises self.failureException if the retcode is
434
452
        not the expected one.