예제 #1
0
파일: test_ui.py 프로젝트: subajat1/thefuck
 def test_with_confirmation_select_second(self, capsys, patch_getch, commands):
     patch_getch(['\x1b', '[', 'B', '\n'])
     assert ui.select_command(commands,
                              Mock(debug=False, no_color=True,
                                   require_confirmation=True)) == commands[1]
     assert capsys.readouterr() == (
         '', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\x1b[1K\rcd [enter/↑/↓/ctrl+c]\n')
예제 #2
0
 def test_without_confirmation_with_side_effects(self, capsys,
                                                 commands_with_side_effect,
                                                 settings):
     settings.require_confirmation = False
     assert (ui.select_command(
         iter(commands_with_side_effect)) == commands_with_side_effect[0])
     assert capsys.readouterr() == ('', 'ls (+side effect)\n')
예제 #3
0
 def test_with_confirmation_with_side_effct(self, capsys, patch_get_key,
                                            commands_with_side_effect):
     patch_get_key(['\n'])
     assert (ui.select_command(
         iter(commands_with_side_effect)) == commands_with_side_effect[0])
     assert capsys.readouterr() == (
         '', u'\x1b[1K\rls (+side effect) [enter/↑/↓/ctrl+c]\n')
예제 #4
0
 def test_with_confirmation(self, capsys, patch_get_key, commands):
     patch_get_key(["\n"])
     assert ui.select_command(iter(commands)) == commands[0]
     assert capsys.readouterr() == (
         "",
         const.USER_COMMAND_MARK + u"\x1b[1K\rls [enter/↑/↓/ctrl+c]\n",
     )
예제 #5
0
 def test_with_confirmation(self, capsys, patch_getch, commands):
     patch_getch(['\n'])
     assert ui.select_command(
         commands,
         Mock(debug=False, no_color=True,
              require_confirmation=True)) == commands[0]
     assert capsys.readouterr() == ('', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\n')
예제 #6
0
 def test_without_confirmation_with_side_effects(self, capsys,
                                                 commands_with_side_effect):
     assert ui.select_command(commands_with_side_effect,
                              Mock(debug=False, no_color=True,
                                   require_confirmation=False)) \
            == commands_with_side_effect[0]
     assert capsys.readouterr() == ('', 'ls (+side effect)\n')
예제 #7
0
파일: test_ui.py 프로젝트: subajat1/thefuck
 def test_without_confirmation_with_side_effects(self, capsys,
                                                 commands_with_side_effect):
     assert ui.select_command(commands_with_side_effect,
                              Mock(debug=False, no_color=True,
                                   require_confirmation=False)) \
            == commands_with_side_effect[0]
     assert capsys.readouterr() == ('', 'ls (+side effect)\n')
예제 #8
0
 def test_with_confirmation_select_second(self, capsys, patch_get_key,
                                          commands):
     patch_get_key([const.KEY_DOWN, '\n'])
     assert ui.select_command(iter(commands)) == commands[1]
     assert capsys.readouterr() == (
         '',
         u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\x1b[1K\rcd [enter/↑/↓/ctrl+c]\n')
예제 #9
0
파일: test_ui.py 프로젝트: subajat1/thefuck
 def test_with_confirmation_with_side_effct(self, capsys, patch_getch,
                                            commands_with_side_effect):
     patch_getch(['\n'])
     assert ui.select_command(commands_with_side_effect,
                              Mock(debug=False, no_color=True,
                                   require_confirmation=True))\
            == commands_with_side_effect[0]
     assert capsys.readouterr() == ('', u'\x1b[1K\rls (+side effect) [enter/↑/↓/ctrl+c]\n')
예제 #10
0
파일: test_ui.py 프로젝트: tgunr/tryagain
 def test_with_confirmation_select_second(self, capsys, patch_get_key, commands):
     patch_get_key([const.KEY_DOWN, '\n'])
     assert ui.select_command(iter(commands)) == commands[1]
     stderr = (
         u'{mark}\x1b[1K\rls [enter/↑/↓/ctrl+c]'
         u'{mark}\x1b[1K\rcd [enter/↑/↓/ctrl+c]\n'
     ).format(mark=const.USER_COMMAND_MARK)
     assert capsys.readouterr() == ('', stderr)
예제 #11
0
 def test_with_confirmation_abort(self, capsys, patch_get_key, commands):
     patch_get_key([const.KEY_CTRL_C])
     assert ui.select_command(iter(commands)) is None
     assert capsys.readouterr() == (
         "",
         const.USER_COMMAND_MARK +
         u"\x1b[1K\rls [enter/↑/↓/ctrl+c]\nAborted\n",
     )
예제 #12
0
 def test_with_confirmation_abort(self, capsys, patch_getch, commands):
     patch_getch([KeyboardInterrupt])
     assert ui.select_command(
         commands,
         Mock(debug=False, no_color=True,
              require_confirmation=True)) is None
     assert capsys.readouterr() == (
         '', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\nAborted\n')
예제 #13
0
 def test_with_confirmation_with_side_effct(self, capsys, patch_getch,
                                            commands_with_side_effect):
     patch_getch(['\n'])
     assert ui.select_command(commands_with_side_effect,
                              Mock(debug=False, no_color=True,
                                   require_confirmation=True))\
            == commands_with_side_effect[0]
     assert capsys.readouterr() == (
         '', u'\x1b[1K\rls (+side effect) [enter/↑/↓/ctrl+c]\n')
예제 #14
0
 def test_without_confirmation_with_side_effects(self, capsys,
                                                 commands_with_side_effect,
                                                 settings):
     settings.require_confirmation = False
     assert (ui.select_command(
         iter(commands_with_side_effect)) == commands_with_side_effect[0])
     assert capsys.readouterr() == (
         "",
         const.USER_COMMAND_MARK + "ls (+side effect)\n",
     )
예제 #15
0
 def test_with_confirmation_with_side_effct(self, capsys, patch_get_key,
                                            commands_with_side_effect):
     patch_get_key(["\n"])
     assert (ui.select_command(
         iter(commands_with_side_effect)) == commands_with_side_effect[0])
     assert capsys.readouterr() == (
         "",
         const.USER_COMMAND_MARK +
         u"\x1b[1K\rls (+side effect) [enter/↑/↓/ctrl+c]\n",
     )
예제 #16
0
 def test_without_confirmation(self, capsys, commands):
     assert ui.select_command(
         commands,
         Mock(debug=False, no_color=True,
              require_confirmation=False)) == commands[0]
     assert capsys.readouterr() == ('', 'ls\n')
예제 #17
0
 def test_without_commands(self, capsys):
     assert ui.select_command([], Mock(debug=False, no_color=True)) is None
     assert capsys.readouterr() == ('', 'No f***s given\n')
예제 #18
0
파일: test_ui.py 프로젝트: subajat1/thefuck
 def test_without_commands(self, capsys):
     assert ui.select_command([], Mock(debug=False, no_color=True)) is None
     assert capsys.readouterr() == ('', 'No f***s given\n')
예제 #19
0
 def test_with_confirmation(self, capsys, patch_get_key, commands):
     patch_get_key(['\n'])
     assert ui.select_command(iter(commands)) == commands[0]
     assert capsys.readouterr() == ('', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\n')
예제 #20
0
 def test_without_confirmation(self, capsys, commands, settings):
     settings.require_confirmation = False
     assert ui.select_command(iter(commands)) == commands[0]
     assert capsys.readouterr() == ('', 'ls\n')
예제 #21
0
 def test_without_confirmation(self, capsys, commands, settings):
     settings.require_confirmation = False
     assert ui.select_command(iter(commands)) == commands[0]
     assert capsys.readouterr() == ('', 'ls\n')
예제 #22
0
 def test_with_confirmation_with_side_effct(self, capsys, patch_get_key,
                                            commands_with_side_effect):
     patch_get_key(['\n'])
     assert ui.select_command(iter(commands_with_side_effect)) \
            == commands_with_side_effect[0]
     assert capsys.readouterr() == ('', u'\x1b[1K\rls (+side effect) [enter/↑/↓/ctrl+c]\n')
예제 #23
0
파일: test_ui.py 프로젝트: Jipoker/thefuck
 def test_with_confirmation_one_match(self, capsys, patch_getch, commands):
     patch_getch(['\n'])
     assert ui.select_command((commands[0],),
                              Mock(debug=False, no_color=True,
                                   require_confirmation=True)) == commands[0]
     assert capsys.readouterr() == ('', u'\x1b[1K\rls [enter/ctrl+c]\n')
예제 #24
0
파일: test_ui.py 프로젝트: MJerty/thefuck
 def test_with_confirmation_abort(self, capsys, patch_getch, commands):
     patch_getch([KeyboardInterrupt])
     assert ui.select_command(iter(commands)) is None
     assert capsys.readouterr() == ('', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\nAborted\n')
예제 #25
0
파일: test_ui.py 프로젝트: subajat1/thefuck
 def test_with_confirmation_abort(self, capsys, patch_getch, commands):
     patch_getch([KeyboardInterrupt])
     assert ui.select_command(commands,
                              Mock(debug=False, no_color=True,
                                   require_confirmation=True)) is None
     assert capsys.readouterr() == ('', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\nAborted\n')
예제 #26
0
 def test_without_confirmation(self, capsys, commands, settings):
     settings.require_confirmation = False
     assert ui.select_command(iter(commands)) == commands[0]
     assert capsys.readouterr() == ("", const.USER_COMMAND_MARK + "ls\n")
예제 #27
0
 def test_without_commands(self, capsys):
     assert ui.select_command(iter([])) is None
     assert capsys.readouterr() == ('', 'No f***s given\n')
예제 #28
0
 def test_with_confirmation_abort(self, capsys, patch_getch, commands):
     patch_getch([KeyboardInterrupt])
     assert ui.select_command(iter(commands)) is None
     assert capsys.readouterr() == (
         '', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\nAborted\n')
예제 #29
0
 def test_without_confirmation_with_side_effects(
         self, capsys, commands_with_side_effect, settings):
     settings.require_confirmation = False
     assert ui.select_command(iter(commands_with_side_effect)) \
            == commands_with_side_effect[0]
     assert capsys.readouterr() == ('', 'ls (+side effect)\n')
예제 #30
0
 def test_with_confirmation(self, capsys, patch_get_key, commands):
     patch_get_key(['\n'])
     assert ui.select_command(iter(commands)) == commands[0]
     assert capsys.readouterr() == ('', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\n')
예제 #31
0
 def test_with_confirmation_abort(self, capsys, patch_get_key, commands):
     patch_get_key([const.KEY_CTRL_C])
     assert ui.select_command(iter(commands)) is None
     assert capsys.readouterr() == ('', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\nAborted\n')
예제 #32
0
파일: test_ui.py 프로젝트: subajat1/thefuck
 def test_without_confirmation(self, capsys, commands):
     assert ui.select_command(commands,
                              Mock(debug=False, no_color=True,
                                   require_confirmation=False)) == commands[0]
     assert capsys.readouterr() == ('', 'ls\n')
예제 #33
0
 def test_with_confirmation_select_second(self, capsys, patch_get_key, commands):
     patch_get_key([const.KEY_DOWN, '\n'])
     assert ui.select_command(iter(commands)) == commands[1]
     assert capsys.readouterr() == (
         '', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\x1b[1K\rcd [enter/↑/↓/ctrl+c]\n')
예제 #34
0
 def test_without_commands(self, capsys):
     assert ui.select_command(iter([])) is None
     assert capsys.readouterr() == ('', 'No f***s given\n')