~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_script.py

  • Committer: Jared Bunting
  • Date: 2010-10-21 22:27:43 UTC
  • mto: This revision was merged to the branch mainline in revision 5514.
  • Revision ID: jared.bunting@peachjean.com-20101021222743-tn9n0cgzg3z8cb25
Changed _win32_local_path_from_url to not allow "file:///C:" form.

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
 
        """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")
 
164
        self.assertRaises(SyntaxError, self.run_script, 'foo')
176
165
 
177
166
    def test_blank_output_mismatches_output(self):
178
167
        """If you give output, the output must actually be blank.
186
175
            $ echo foo
187
176
            """)
188
177
 
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
 
 
197
178
    def test_ellipsis_everything(self):
198
179
        """A simple ellipsis matches everything."""
199
180
        self.run_script("""
383
364
$ mkdir ../dir2
384
365
$ cd ..
385
366
""")
386
 
        self.assertPathExists('dir')
387
 
        self.assertPathExists('dir2')
 
367
        self.failUnlessExists('dir')
 
368
        self.failUnlessExists('dir2')
388
369
 
389
370
 
390
371
class TestCd(script.TestCaseWithTransportAndScript):
416
397
            $ bzr init branch
417
398
            Created a standalone tree (format: ...)
418
399
            """)
419
 
        self.assertPathExists('branch')
 
400
        self.failUnlessExists('branch')
420
401
 
421
402
 
422
403
class TestEcho(script.TestCaseWithMemoryTransportAndScript):
480
461
 
481
462
    def test_rm_file(self):
482
463
        self.run_script('$ echo content >file')
483
 
        self.assertPathExists('file')
 
464
        self.failUnlessExists('file')
484
465
        self.run_script('$ rm file')
485
 
        self.assertPathDoesNotExist('file')
 
466
        self.failIfExists('file')
486
467
 
487
468
    def test_rm_file_force(self):
488
 
        self.assertPathDoesNotExist('file')
 
469
        self.failIfExists('file')
489
470
        self.run_script('$ rm -f file')
490
 
        self.assertPathDoesNotExist('file')
 
471
        self.failIfExists('file')
491
472
 
492
473
    def test_rm_files(self):
493
474
        self.run_script("""
494
475
$ echo content >file
495
476
$ echo content >file2
496
477
""")
497
 
        self.assertPathExists('file2')
 
478
        self.failUnlessExists('file2')
498
479
        self.run_script('$ rm file file2')
499
 
        self.assertPathDoesNotExist('file2')
 
480
        self.failIfExists('file2')
500
481
 
501
482
    def test_rm_dir(self):
502
483
        self.run_script('$ mkdir dir')
503
 
        self.assertPathExists('dir')
 
484
        self.failUnlessExists('dir')
504
485
        self.run_script("""
505
486
$ rm dir
506
487
2>rm: cannot remove 'dir': Is a directory
507
488
""")
508
 
        self.assertPathExists('dir')
 
489
        self.failUnlessExists('dir')
509
490
 
510
491
    def test_rm_dir_recursive(self):
511
492
        self.run_script("""
512
493
$ mkdir dir
513
494
$ rm -r dir
514
495
""")
515
 
        self.assertPathDoesNotExist('dir')
 
496
        self.failIfExists('dir')
516
497
 
517
498
 
518
499
class TestMv(script.TestCaseWithTransportAndScript):
524
505
 
525
506
    def test_move_file(self):
526
507
        self.run_script('$ echo content >file')
527
 
        self.assertPathExists('file')
 
508
        self.failUnlessExists('file')
528
509
        self.run_script('$ mv file new_name')
529
 
        self.assertPathDoesNotExist('file')
530
 
        self.assertPathExists('new_name')
 
510
        self.failIfExists('file')
 
511
        self.failUnlessExists('new_name')
531
512
 
532
513
    def test_move_unknown_file(self):
533
514
        self.assertRaises(AssertionError,
539
520
$ echo content >dir/file
540
521
""")
541
522
        self.run_script('$ mv dir new_name')
542
 
        self.assertPathDoesNotExist('dir')
543
 
        self.assertPathExists('new_name')
544
 
        self.assertPathExists('new_name/file')
 
523
        self.failIfExists('dir')
 
524
        self.failUnlessExists('new_name')
 
525
        self.failUnlessExists('new_name/file')
545
526
 
546
527
    def test_move_file_into_dir(self):
547
528
        self.run_script("""
549
530
$ echo content > file
550
531
""")
551
532
        self.run_script('$ mv file dir')
552
 
        self.assertPathExists('dir')
553
 
        self.assertPathDoesNotExist('file')
554
 
        self.assertPathExists('dir/file')
 
533
        self.failUnlessExists('dir')
 
534
        self.failIfExists('file')
 
535
        self.failUnlessExists('dir/file')
555
536
 
556
537
 
557
538
class cmd_test_confirm(commands.Command):