~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_script.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009 Canonical Ltd
 
1
# Copyright (C) 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
262
262
2>: No such file or directory
263
263
""")
264
264
 
265
 
    def test_echo_bogus_input_file(self):
266
 
        # We need a backing file sysytem for that test so it can't be in
267
 
        # TestEcho
268
 
        self.run_script("""
269
 
$ echo <file
270
 
2>file: No such file or directory
271
 
""")
272
 
 
273
265
    def test_echo_bogus_output_file(self):
274
266
        # We need a backing file sysytem for that test so it can't be in
275
267
        # TestEcho
338
330
"""
339
331
        self.assertRaises(SyntaxError, self.run_script, story)
340
332
 
 
333
    def test_echo_input(self):
 
334
        self.assertRaises(SyntaxError, self.run_script, """
 
335
            $ echo <foo
 
336
            """)
 
337
 
341
338
    def test_echo_to_output(self):
342
339
        retcode, out, err = self.run_command(['echo'], None, '\n', None)
343
340
        self.assertEquals('\n', out)
410
407
$ rm -r dir
411
408
""")
412
409
        self.failIfExists('dir')
 
410
 
 
411
 
 
412
class TestMv(script.TestCaseWithTransportAndScript):
 
413
 
 
414
    def test_usage(self):
 
415
        self.assertRaises(SyntaxError, self.run_script, '$ mv')
 
416
        self.assertRaises(SyntaxError, self.run_script, '$ mv f')
 
417
        self.assertRaises(SyntaxError, self.run_script, '$ mv f1 f2 f3')
 
418
 
 
419
    def test_move_file(self):
 
420
        self.run_script('$ echo content >file')
 
421
        self.failUnlessExists('file')
 
422
        self.run_script('$ mv file new_name')
 
423
        self.failIfExists('file')
 
424
        self.failUnlessExists('new_name')
 
425
 
 
426
    def test_move_unknown_file(self):
 
427
        self.assertRaises(AssertionError,
 
428
                          self.run_script, '$ mv unknown does-not-exist')
 
429
 
 
430
    def test_move_dir(self):
 
431
        self.run_script("""
 
432
$ mkdir dir
 
433
$ echo content >dir/file
 
434
""")
 
435
        self.run_script('$ mv dir new_name')
 
436
        self.failIfExists('dir')
 
437
        self.failUnlessExists('new_name')
 
438
        self.failUnlessExists('new_name/file')
 
439
 
 
440
    def test_move_file_into_dir(self):
 
441
        self.run_script("""
 
442
$ mkdir dir
 
443
$ echo content > file
 
444
""")
 
445
        self.run_script('$ mv file dir')
 
446
        self.failUnlessExists('dir')
 
447
        self.failIfExists('file')
 
448
        self.failUnlessExists('dir/file')
 
449