~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/script.py

  • Committer: Vincent Ladeuil
  • Date: 2009-12-09 15:09:00 UTC
  • mto: (4881.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4882.
  • Revision ID: v.ladeuil+lp@free.fr-20091209150900-pbytmi9fh4fa3vbf
Fix broken test (fail on windows).

* bzrlib/tests/test_osutils.py:
(TestTerminalWidth.test_falls_back_to_COLUMNS): COLUMNS makes
sense for ttys only.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009 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
107
107
                error = []
108
108
            error.append(line[2:] + '\n')
109
109
        else:
110
 
            # can happen if the first line is not recognized as a command, eg
111
 
            # if the prompt has leading whitespace
112
110
            if output is None:
113
111
                if cmd_cur is None:
114
 
                    raise SyntaxError('No command for line %r' % (line,),
 
112
                    raise SyntaxError('No command for that output',
115
113
                                      (file_name, lineno, 1, orig))
116
114
                output = []
117
115
            output.append(line + '\n')
402
400
            retcode = 0
403
401
        return retcode, None, err
404
402
 
405
 
    def do_mv(self, test_case, input, args):
406
 
        err = None
407
 
        def error(msg, src, dst):
408
 
            return "mv: cannot move %s to %s: %s\n" % (src, dst, msg)
409
 
 
410
 
        if not args or len(args) != 2:
411
 
            raise SyntaxError("Usage: mv path1 path2")
412
 
        src, dst = args
413
 
        try:
414
 
            real_dst = dst
415
 
            if os.path.isdir(dst):
416
 
                real_dst = os.path.join(dst, os.path.basename(src))
417
 
            os.rename(src, real_dst)
418
 
        except OSError, e:
419
 
            if e.errno == errno.ENOENT:
420
 
                err = error('No such file or directory', src, dst)
421
 
            else:
422
 
                raise
423
 
        if err:
424
 
            retcode = 1
425
 
        else:
426
 
            retcode = 0
427
 
        return retcode, None, err
428
 
 
429
 
 
430
403
 
431
404
class TestCaseWithMemoryTransportAndScript(tests.TestCaseWithMemoryTransport):
432
405
    """Helper class to experiment shell-like test and memory fs.