~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2007-08-20 13:07:12 UTC
  • mfrom: (2732 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2733.
  • Revision ID: abentley@panoramicfeedback.com-20070820130712-buopmg528zcgwyxc
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
270
270
    def test_run_bzr_subprocess(self):
271
271
        """The run_bzr_helper_external comand behaves nicely."""
272
272
        result = self.run_bzr_subprocess('--version')
 
273
        result = self.run_bzr_subprocess(['--version'])
273
274
        result = self.run_bzr_subprocess('--version', retcode=None)
274
275
        self.assertContainsRe(result[0], 'is free software')
275
276
        self.assertRaises(AssertionError, self.run_bzr_subprocess, 
277
278
        result = self.run_bzr_subprocess('--versionn', retcode=3)
278
279
        result = self.run_bzr_subprocess('--versionn', retcode=None)
279
280
        self.assertContainsRe(result[1], 'unknown command')
280
 
        err = self.run_bzr_subprocess('merge', '--merge-type', 'magic merge', 
281
 
                                      retcode=3)[1]
 
281
        err = self.run_bzr_subprocess(['merge', '--merge-type',
 
282
                                      'magic merge'], retcode=3)[1]
282
283
        self.assertContainsRe(err, 'Bad value "magic merge" for option'
283
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)
284
289
 
285
290
    def test_run_bzr_subprocess_env(self):
286
291
        """run_bzr_subprocess can set environment variables in the child only.
392
397
        raise _DontSpawnProcess()
393
398
 
394
399
    def test_run_bzr_subprocess_no_plugins(self):
395
 
        self.assertRaises(_DontSpawnProcess, self.run_bzr_subprocess)
 
400
        self.assertRaises(_DontSpawnProcess, self.run_bzr_subprocess, '')
396
401
        command = self._popen_args[0]
397
402
        self.assertEqual(sys.executable, command[0])
398
403
        self.assertEqual(self.get_bzr_path(), command[1])
400
405
 
401
406
    def test_allow_plugins(self):
402
407
        self.assertRaises(_DontSpawnProcess,
403
 
                          self.run_bzr_subprocess, allow_plugins=True)
 
408
                          self.run_bzr_subprocess, '', allow_plugins=True)
404
409
        command = self._popen_args[0]
405
410
        self.assertEqual([], command[2:])
406
411
 
481
486
    @staticmethod
482
487
    def _parse_test_list(lines, newlines_in_header=1):
483
488
        "Parse a list of lines into a tuple of 3 lists (header,body,footer)."
484
 
 
485
489
        in_header = True
486
490
        in_footer = False
487
491
        header = []
488
492
        body = []
489
493
        footer = []
490
 
        header_newlines_found = 0 
 
494
        header_newlines_found = 0
491
495
        for line in lines:
492
496
            if in_header:
493
497
                if line == '':
505
509
                footer.append(line)
506
510
        # If the last body line is blank, drop it off the list
507
511
        if len(body) > 0 and body[-1] == '':
508
 
            body.pop()                
 
512
            body.pop()
509
513
        return (header,body,footer)
510
514
 
511
515
    def test_list_only(self):
545
549
                                          'selftest', '--randomize', 'now'])
546
550
        (header_rand,tests_rand,dummy) = self._parse_test_list(
547
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.
548
557
        self.assertNotEqual(tests_all, tests_rand)
549
558
        self.assertEqual(sorted(tests_all), sorted(tests_rand))
550
559
        # Check that the seed can be reused to get the exact same order