Exemple #1
0
 def sig_path_prompt(self, sender, prompt, callback, args=()):
     signals.focus.send(self, section="footer")
     self._w = pathedit.PathEdit(
         self.prep_prompt(prompt),
         os.path.dirname(self.last_path)
     )
     self.pathprompt = True
     self.prompting = (callback, args)
Exemple #2
0
    def test_keypress(self):

        pe = pathedit.PathEdit()

        with patch('urwid.widget.Edit.get_edit_text') as get_text, \
                patch('urwid.widget.Edit.set_edit_text') as set_text:

            cd = tutils.test_data.path("completion")
            get_text.return_value = os.path.join(cd, "a")

            # Pressing tab should set completed path
            pe.keypress((1, ), "tab")
            set_text_called_with = set_text.call_args[0][0]
            assert set_text_called_with.endswith(normpath("/completion/aaa"))

            # Pressing any other key should reset
            pe.keypress((1, ), "a")
            assert pe.lookup is None