/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tests/test_bashcomp.py

Reformat bash input snippet.

Instead of a single multiline string with a dictionary of substitutions, we
now build the snippet one line at a time, using normal python indentation
and providing never more than a single value for substitution.

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
                                stderr=subprocess.PIPE)
71
71
        if cword < 0:
72
72
            cword = len(words) + cword
73
 
        input = """
74
 
%(script)s
75
 
 
76
 
COMP_WORDS=( %(words)s )
77
 
COMP_CWORD=%(cword)d
78
 
%(name)s
79
 
echo ${#COMPREPLY[*]}
80
 
IFS=$'\\n'
81
 
echo "${COMPREPLY[*]}"
82
 
""" % { 'script': self.script,
83
 
        'words': 
84
 
        'cword': cword,
85
 
        'name': getattr(self, 'script_name', '_bzr'),
86
 
      }
 
73
        input = '%s\n' % self.script
 
74
        input += ('COMP_WORDS=( %s )\n' %
 
75
                  ' '.join(["'"+w.replace("'", "'\\''")+"'" for w in words]))
 
76
        input += 'COMP_CWORD=%d\n' % cword
 
77
        input += '%s\n' % getattr(self, 'script_name', '_bzr')
 
78
        input += 'echo ${#COMPREPLY[*]}\n'
 
79
        input += "IFS=$'\\n'\n"
 
80
        input += 'echo "${COMPREPLY[*]}"\n'
87
81
        (out, err) = proc.communicate(input)
88
82
        if '' != err:
89
83
            raise AssertionError('Unexpected error message:\n%s' % err)