Ejemplo n.º 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 = PromptPath(callback, args)
Ejemplo n.º 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 = os.path.normpath(tutils.test_data.path("mitmproxy/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