~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/bash_completion/tests/test_bashcomp.py

Merge cleanup into first-try

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import subprocess
23
23
 
24
24
 
25
 
class _BashFeature(tests.Feature):
26
 
    """Feature testing whether a bash executable is available."""
27
 
 
28
 
    bash_paths = ['/bin/bash', '/usr/bin/bash']
29
 
 
30
 
    def __init__(self):
31
 
        super(_BashFeature, self).__init__()
32
 
        self.bash_path = None
33
 
 
34
 
    def available(self):
35
 
        if self.bash_path is not None:
36
 
            return self.bash_path is not False
37
 
        for path in self.bash_paths:
38
 
            if os.access(path, os.X_OK):
39
 
                self.bash_path = path
40
 
                return True
41
 
        self.bash_path = False
42
 
        return False
43
 
 
44
 
    def feature_name(self):
45
 
        return 'bash'
46
 
 
47
 
BashFeature = _BashFeature()
48
 
 
49
 
 
50
25
class BashCompletionMixin(object):
51
26
    """Component for testing execution of a bash completion script."""
52
27
 
53
 
    _test_needs_features = [BashFeature]
 
28
    _test_needs_features = [tests.features.bash_feature]
54
29
 
55
30
    def complete(self, words, cword=-1):
56
31
        """Perform a bash completion.
60
35
        """
61
36
        if self.script is None:
62
37
            self.script = self.get_script()
63
 
        proc = subprocess.Popen([BashFeature.bash_path, '--noprofile'],
 
38
        proc = subprocess.Popen([tests.features.bash_feature.path,
 
39
                                 '--noprofile'],
64
40
                                stdin=subprocess.PIPE,
65
41
                                stdout=subprocess.PIPE,
66
42
                                stderr=subprocess.PIPE)
187
163
        return s.replace("$(bzr ", "$('%s' " % self.get_bzr_path())
188
164
 
189
165
    def test_revspec_tag_all(self):
 
166
        self.requireFeature(tests.features.sed_feature)
190
167
        wt = self.make_branch_and_tree('.', format='dirstate-tags')
191
168
        wt.branch.tags.set_tag('tag1', 'null:')
192
169
        wt.branch.tags.set_tag('tag2', 'null:')
195
172
        self.assertCompletionEquals('tag1', 'tag2', '3tag')
196
173
 
197
174
    def test_revspec_tag_prefix(self):
 
175
        self.requireFeature(tests.features.sed_feature)
198
176
        wt = self.make_branch_and_tree('.', format='dirstate-tags')
199
177
        wt.branch.tags.set_tag('tag1', 'null:')
200
178
        wt.branch.tags.set_tag('tag2', 'null:')