/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: Aaron Bentley
  • Date: 2007-08-15 16:05:13 UTC
  • mfrom: (2703 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2709.
  • Revision ID: abentley@panoramicfeedback.com-20070815160513-aepyrd0uu9vtedsy
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
172
172
        self.assertEqual('baz', self.working_dir)
173
173
        self.assertEqual(['foo', 'bar'], self.argv)
174
174
 
 
175
    def test_reject_extra_keyword_arguments(self):
 
176
        self.assertRaises(TypeError, self.run_bzr, "foo bar",
 
177
                          error_regex=['error message'])
 
178
 
175
179
 
176
180
class TestBenchmarkTests(TestCaseWithTransport):
177
181
 
266
270
    def test_run_bzr_subprocess(self):
267
271
        """The run_bzr_helper_external comand behaves nicely."""
268
272
        result = self.run_bzr_subprocess('--version')
 
273
        result = self.run_bzr_subprocess(['--version'])
269
274
        result = self.run_bzr_subprocess('--version', retcode=None)
270
275
        self.assertContainsRe(result[0], 'is free software')
271
276
        self.assertRaises(AssertionError, self.run_bzr_subprocess, 
273
278
        result = self.run_bzr_subprocess('--versionn', retcode=3)
274
279
        result = self.run_bzr_subprocess('--versionn', retcode=None)
275
280
        self.assertContainsRe(result[1], 'unknown command')
276
 
        err = self.run_bzr_subprocess('merge', '--merge-type', 'magic merge', 
277
 
                                      retcode=3)[1]
 
281
        err = self.run_bzr_subprocess(['merge', '--merge-type',
 
282
                                      'magic merge'], retcode=3)[1]
278
283
        self.assertContainsRe(err, 'Bad value "magic merge" for option'
279
284
                              ' "merge-type"')
 
285
        self.callDeprecated(['passing varargs to run_bzr_subprocess was'
 
286
                             ' deprecated in version 0.91.'],
 
287
                            self.run_bzr_subprocess,
 
288
                            'arg1', 'arg2', 'arg3', retcode=3)
280
289
 
281
290
    def test_run_bzr_subprocess_env(self):
282
291
        """run_bzr_subprocess can set environment variables in the child only.
388
397
        raise _DontSpawnProcess()
389
398
 
390
399
    def test_run_bzr_subprocess_no_plugins(self):
391
 
        self.assertRaises(_DontSpawnProcess, self.run_bzr_subprocess)
 
400
        self.assertRaises(_DontSpawnProcess, self.run_bzr_subprocess, '')
392
401
        command = self._popen_args[0]
393
402
        self.assertEqual(sys.executable, command[0])
394
403
        self.assertEqual(self.get_bzr_path(), command[1])
396
405
 
397
406
    def test_allow_plugins(self):
398
407
        self.assertRaises(_DontSpawnProcess,
399
 
                          self.run_bzr_subprocess, allow_plugins=True)
 
408
                          self.run_bzr_subprocess, '', allow_plugins=True)
400
409
        command = self._popen_args[0]
401
410
        self.assertEqual([], command[2:])
402
411
 
477
486
    @staticmethod
478
487
    def _parse_test_list(lines, newlines_in_header=1):
479
488
        "Parse a list of lines into a tuple of 3 lists (header,body,footer)."
480
 
 
481
489
        in_header = True
482
490
        in_footer = False
483
491
        header = []
484
492
        body = []
485
493
        footer = []
486
 
        header_newlines_found = 0 
 
494
        header_newlines_found = 0
487
495
        for line in lines:
488
496
            if in_header:
489
497
                if line == '':
501
509
                footer.append(line)
502
510
        # If the last body line is blank, drop it off the list
503
511
        if len(body) > 0 and body[-1] == '':
504
 
            body.pop()                
 
512
            body.pop()
505
513
        return (header,body,footer)
506
514
 
507
515
    def test_list_only(self):
541
549
                                          'selftest', '--randomize', 'now'])
542
550
        (header_rand,tests_rand,dummy) = self._parse_test_list(
543
551
            out_rand.splitlines(), 2)
 
552
        # XXX: The following line asserts that the randomized order is not the
 
553
        # same as the default order.  It is just possible that they'll get
 
554
        # randomized into the same order and this will falsely fail, but
 
555
        # that's very unlikely in practice because there are thousands of
 
556
        # tests.
544
557
        self.assertNotEqual(tests_all, tests_rand)
545
558
        self.assertEqual(sorted(tests_all), sorted(tests_rand))
546
559
        # Check that the seed can be reused to get the exact same order