~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_script.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-04-18 04:55:00 UTC
  • mfrom: (5784.2.1 754188-apport-test)
  • Revision ID: pqm@pqm.ubuntu.com-20110418045500-ce6lkgyiq7f47q43
(mbp) Rewrite test_report_bug_legacy away from using doctest (see bug
 764188) (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
161
161
class TestExecution(script.TestCaseWithTransportAndScript):
162
162
 
163
163
    def test_unknown_command(self):
164
 
        self.assertRaises(SyntaxError, self.run_script, 'foo')
 
164
        """A clear error is reported for commands that aren't recognised
 
165
 
 
166
        Testing the attributes of the SyntaxError instance is equivalent to
 
167
        using traceback.format_exception_only and comparing with:
 
168
          File "<string>", line 1
 
169
            foo --frob
 
170
            ^
 
171
        SyntaxError: Command not found "foo"
 
172
        """
 
173
        e = self.assertRaises(SyntaxError, self.run_script, "$ foo --frob")
 
174
        self.assertContainsRe(e.msg, "not found.*foo")
 
175
        self.assertEquals(e.text, "foo --frob")
165
176
 
166
177
    def test_blank_output_mismatches_output(self):
167
178
        """If you give output, the output must actually be blank.
175
186
            $ echo foo
176
187
            """)
177
188
 
 
189
    def test_null_output_matches_option(self):
 
190
        """If you want null output to be a wild card, you can pass 
 
191
        null_output_matches_anything to run_script"""
 
192
        self.run_script(
 
193
            """
 
194
            $ echo foo
 
195
            """, null_output_matches_anything=True)
 
196
 
178
197
    def test_ellipsis_everything(self):
179
198
        """A simple ellipsis matches everything."""
180
199
        self.run_script("""
364
383
$ mkdir ../dir2
365
384
$ cd ..
366
385
""")
367
 
        self.failUnlessExists('dir')
368
 
        self.failUnlessExists('dir2')
 
386
        self.assertPathExists('dir')
 
387
        self.assertPathExists('dir2')
369
388
 
370
389
 
371
390
class TestCd(script.TestCaseWithTransportAndScript):
397
416
            $ bzr init branch
398
417
            Created a standalone tree (format: ...)
399
418
            """)
400
 
        self.failUnlessExists('branch')
 
419
        self.assertPathExists('branch')
401
420
 
402
421
 
403
422
class TestEcho(script.TestCaseWithMemoryTransportAndScript):
461
480
 
462
481
    def test_rm_file(self):
463
482
        self.run_script('$ echo content >file')
464
 
        self.failUnlessExists('file')
 
483
        self.assertPathExists('file')
465
484
        self.run_script('$ rm file')
466
 
        self.failIfExists('file')
 
485
        self.assertPathDoesNotExist('file')
467
486
 
468
487
    def test_rm_file_force(self):
469
 
        self.failIfExists('file')
 
488
        self.assertPathDoesNotExist('file')
470
489
        self.run_script('$ rm -f file')
471
 
        self.failIfExists('file')
 
490
        self.assertPathDoesNotExist('file')
472
491
 
473
492
    def test_rm_files(self):
474
493
        self.run_script("""
475
494
$ echo content >file
476
495
$ echo content >file2
477
496
""")
478
 
        self.failUnlessExists('file2')
 
497
        self.assertPathExists('file2')
479
498
        self.run_script('$ rm file file2')
480
 
        self.failIfExists('file2')
 
499
        self.assertPathDoesNotExist('file2')
481
500
 
482
501
    def test_rm_dir(self):
483
502
        self.run_script('$ mkdir dir')
484
 
        self.failUnlessExists('dir')
 
503
        self.assertPathExists('dir')
485
504
        self.run_script("""
486
505
$ rm dir
487
506
2>rm: cannot remove 'dir': Is a directory
488
507
""")
489
 
        self.failUnlessExists('dir')
 
508
        self.assertPathExists('dir')
490
509
 
491
510
    def test_rm_dir_recursive(self):
492
511
        self.run_script("""
493
512
$ mkdir dir
494
513
$ rm -r dir
495
514
""")
496
 
        self.failIfExists('dir')
 
515
        self.assertPathDoesNotExist('dir')
497
516
 
498
517
 
499
518
class TestMv(script.TestCaseWithTransportAndScript):
505
524
 
506
525
    def test_move_file(self):
507
526
        self.run_script('$ echo content >file')
508
 
        self.failUnlessExists('file')
 
527
        self.assertPathExists('file')
509
528
        self.run_script('$ mv file new_name')
510
 
        self.failIfExists('file')
511
 
        self.failUnlessExists('new_name')
 
529
        self.assertPathDoesNotExist('file')
 
530
        self.assertPathExists('new_name')
512
531
 
513
532
    def test_move_unknown_file(self):
514
533
        self.assertRaises(AssertionError,
520
539
$ echo content >dir/file
521
540
""")
522
541
        self.run_script('$ mv dir new_name')
523
 
        self.failIfExists('dir')
524
 
        self.failUnlessExists('new_name')
525
 
        self.failUnlessExists('new_name/file')
 
542
        self.assertPathDoesNotExist('dir')
 
543
        self.assertPathExists('new_name')
 
544
        self.assertPathExists('new_name/file')
526
545
 
527
546
    def test_move_file_into_dir(self):
528
547
        self.run_script("""
530
549
$ echo content > file
531
550
""")
532
551
        self.run_script('$ mv file dir')
533
 
        self.failUnlessExists('dir')
534
 
        self.failIfExists('file')
535
 
        self.failUnlessExists('dir/file')
 
552
        self.assertPathExists('dir')
 
553
        self.assertPathDoesNotExist('file')
 
554
        self.assertPathExists('dir/file')
536
555
 
537
556
 
538
557
class cmd_test_confirm(commands.Command):