161
160
class TestExecution(script.TestCaseWithTransportAndScript):
163
162
def test_unknown_command(self):
164
"""A clear error is reported for commands that aren't recognised
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
171
SyntaxError: Command not found "foo"
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")
177
def test_blank_output_mismatches_output(self):
178
"""If you give output, the output must actually be blank.
180
See <https://bugs.launchpad.net/bzr/+bug/637830>: previously blank
181
output was a wildcard. Now you must say ... if you want that.
183
self.assertRaises(AssertionError,
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"""
195
""", null_output_matches_anything=True)
197
def test_ellipsis_everything(self):
198
"""A simple ellipsis matches everything."""
204
def test_ellipsis_matches_empty(self):
163
self.assertRaises(SyntaxError, self.run_script, 'foo')
210
165
def test_stops_on_unexpected_output(self):
292
245
cat dog "chicken" 'dragon'
295
def test_verbosity_isolated(self):
296
"""Global verbosity is isolated from commands run in scripts.
298
# see also 656694; we should get rid of global verbosity
302
self.assertEquals(trace.is_quiet(), False)
305
249
class TestCat(script.TestCaseWithTransportAndScript):
386
self.assertPathExists('dir')
387
self.assertPathExists('dir2')
330
self.failUnlessExists('dir')
331
self.failUnlessExists('dir2')
390
334
class TestCd(script.TestCaseWithTransportAndScript):
412
356
class TestBzr(script.TestCaseWithTransportAndScript):
414
358
def test_bzr_smoke(self):
417
Created a standalone tree (format: ...)
419
self.assertPathExists('branch')
359
self.run_script('$ bzr init branch')
360
self.failUnlessExists('branch')
422
363
class TestEcho(script.TestCaseWithMemoryTransportAndScript):
481
422
def test_rm_file(self):
482
423
self.run_script('$ echo content >file')
483
self.assertPathExists('file')
424
self.failUnlessExists('file')
484
425
self.run_script('$ rm file')
485
self.assertPathDoesNotExist('file')
426
self.failIfExists('file')
487
428
def test_rm_file_force(self):
488
self.assertPathDoesNotExist('file')
429
self.failIfExists('file')
489
430
self.run_script('$ rm -f file')
490
self.assertPathDoesNotExist('file')
431
self.failIfExists('file')
492
433
def test_rm_files(self):
493
434
self.run_script("""
494
435
$ echo content >file
495
436
$ echo content >file2
497
self.assertPathExists('file2')
438
self.failUnlessExists('file2')
498
439
self.run_script('$ rm file file2')
499
self.assertPathDoesNotExist('file2')
440
self.failIfExists('file2')
501
442
def test_rm_dir(self):
502
443
self.run_script('$ mkdir dir')
503
self.assertPathExists('dir')
444
self.failUnlessExists('dir')
504
445
self.run_script("""
506
447
2>rm: cannot remove 'dir': Is a directory
508
self.assertPathExists('dir')
449
self.failUnlessExists('dir')
510
451
def test_rm_dir_recursive(self):
511
452
self.run_script("""
515
self.assertPathDoesNotExist('dir')
456
self.failIfExists('dir')
518
459
class TestMv(script.TestCaseWithTransportAndScript):
525
466
def test_move_file(self):
526
467
self.run_script('$ echo content >file')
527
self.assertPathExists('file')
468
self.failUnlessExists('file')
528
469
self.run_script('$ mv file new_name')
529
self.assertPathDoesNotExist('file')
530
self.assertPathExists('new_name')
470
self.failIfExists('file')
471
self.failUnlessExists('new_name')
532
473
def test_move_unknown_file(self):
533
474
self.assertRaises(AssertionError,
539
480
$ echo content >dir/file
541
482
self.run_script('$ mv dir new_name')
542
self.assertPathDoesNotExist('dir')
543
self.assertPathExists('new_name')
544
self.assertPathExists('new_name/file')
483
self.failIfExists('dir')
484
self.failUnlessExists('new_name')
485
self.failUnlessExists('new_name/file')
546
487
def test_move_file_into_dir(self):
547
488
self.run_script("""
549
490
$ echo content > file
551
492
self.run_script('$ mv file dir')
552
self.assertPathExists('dir')
553
self.assertPathDoesNotExist('file')
554
self.assertPathExists('dir/file')
493
self.failUnlessExists('dir')
494
self.failIfExists('file')
495
self.failUnlessExists('dir/file')
557
498
class cmd_test_confirm(commands.Command):