2015-07-29 16:30:32 +03:00
|
|
|
def _set_confirmation(proc, require):
|
|
|
|
proc.sendline(u'mkdir -p ~/.thefuck')
|
|
|
|
proc.sendline(
|
|
|
|
u'echo "require_confirmation = {}" > ~/.thefuck/settings.py'.format(
|
|
|
|
require))
|
|
|
|
|
|
|
|
|
2015-09-06 00:56:18 +03:00
|
|
|
def with_confirmation(proc, TIMEOUT):
|
2015-07-24 08:04:49 +03:00
|
|
|
"""Ensures that command can be fixed when confirmation enabled."""
|
2015-07-29 16:30:32 +03:00
|
|
|
_set_confirmation(proc, True)
|
2015-07-25 03:01:03 +03:00
|
|
|
|
2015-07-25 03:22:05 +03:00
|
|
|
proc.sendline(u'ehco test')
|
2015-07-24 08:04:49 +03:00
|
|
|
|
2015-07-25 03:22:05 +03:00
|
|
|
proc.sendline(u'fuck')
|
2015-07-25 21:02:04 +03:00
|
|
|
assert proc.expect([TIMEOUT, u'echo test'])
|
|
|
|
assert proc.expect([TIMEOUT, u'enter'])
|
|
|
|
assert proc.expect_exact([TIMEOUT, u'ctrl+c'])
|
2015-07-24 08:04:49 +03:00
|
|
|
proc.send('\n')
|
|
|
|
|
2015-07-25 21:02:04 +03:00
|
|
|
assert proc.expect([TIMEOUT, u'test'])
|
2015-07-24 08:04:49 +03:00
|
|
|
|
|
|
|
|
2015-09-06 00:56:18 +03:00
|
|
|
def history_changed(proc, TIMEOUT, to):
|
2015-07-27 17:28:09 +03:00
|
|
|
"""Ensures that history changed."""
|
|
|
|
proc.send('\033[A')
|
2015-07-29 16:30:32 +03:00
|
|
|
assert proc.expect([TIMEOUT, to])
|
2015-07-27 17:28:09 +03:00
|
|
|
|
|
|
|
|
2015-09-06 00:56:18 +03:00
|
|
|
def history_not_changed(proc, TIMEOUT):
|
2015-07-27 17:28:09 +03:00
|
|
|
"""Ensures that history not changed."""
|
|
|
|
proc.send('\033[A')
|
2015-07-27 17:51:33 +03:00
|
|
|
assert proc.expect([TIMEOUT, u'fuck'])
|
2015-07-27 17:28:09 +03:00
|
|
|
|
|
|
|
|
2015-09-06 00:56:18 +03:00
|
|
|
def select_command_with_arrows(proc, TIMEOUT):
|
2015-07-30 18:28:20 +03:00
|
|
|
"""Ensures that command can be selected with arrow keys."""
|
|
|
|
_set_confirmation(proc, True)
|
|
|
|
|
|
|
|
proc.sendline(u'git h')
|
|
|
|
assert proc.expect([TIMEOUT, u"git: 'h' is not a git command."])
|
|
|
|
|
|
|
|
proc.sendline(u'fuck')
|
|
|
|
assert proc.expect([TIMEOUT, u'git show'])
|
|
|
|
proc.send('\033[B')
|
|
|
|
assert proc.expect([TIMEOUT, u'git push'])
|
|
|
|
proc.send('\033[B')
|
|
|
|
assert proc.expect([TIMEOUT, u'git help'])
|
|
|
|
proc.send('\033[A')
|
|
|
|
assert proc.expect([TIMEOUT, u'git push'])
|
2015-09-06 01:24:29 +03:00
|
|
|
proc.send('\033[B')
|
|
|
|
assert proc.expect([TIMEOUT, u'git help'])
|
2015-07-30 18:28:20 +03:00
|
|
|
proc.send('\n')
|
|
|
|
|
2015-09-06 01:24:29 +03:00
|
|
|
assert proc.expect([TIMEOUT, u'usage'])
|
2015-07-30 18:28:20 +03:00
|
|
|
|
|
|
|
|
2015-09-06 00:56:18 +03:00
|
|
|
def refuse_with_confirmation(proc, TIMEOUT):
|
2015-07-24 23:14:58 +03:00
|
|
|
"""Ensures that fix can be refused when confirmation enabled."""
|
2015-07-29 16:30:32 +03:00
|
|
|
_set_confirmation(proc, True)
|
2015-07-25 03:01:03 +03:00
|
|
|
|
2015-07-25 03:22:05 +03:00
|
|
|
proc.sendline(u'ehco test')
|
2015-07-24 23:14:58 +03:00
|
|
|
|
2015-07-25 03:22:05 +03:00
|
|
|
proc.sendline(u'fuck')
|
2015-07-25 21:02:04 +03:00
|
|
|
assert proc.expect([TIMEOUT, u'echo test'])
|
|
|
|
assert proc.expect([TIMEOUT, u'enter'])
|
|
|
|
assert proc.expect_exact([TIMEOUT, u'ctrl+c'])
|
2015-07-24 23:14:58 +03:00
|
|
|
proc.send('\003')
|
|
|
|
|
2015-07-25 21:02:04 +03:00
|
|
|
assert proc.expect([TIMEOUT, u'Aborted'])
|
2015-07-24 23:14:58 +03:00
|
|
|
|
|
|
|
|
2015-09-06 00:56:18 +03:00
|
|
|
def without_confirmation(proc, TIMEOUT):
|
2015-07-24 08:04:49 +03:00
|
|
|
"""Ensures that command can be fixed when confirmation disabled."""
|
2015-07-29 16:30:32 +03:00
|
|
|
_set_confirmation(proc, False)
|
2015-07-25 03:01:03 +03:00
|
|
|
|
2015-07-25 03:22:05 +03:00
|
|
|
proc.sendline(u'ehco test')
|
2015-07-24 08:04:49 +03:00
|
|
|
|
2015-07-25 03:22:05 +03:00
|
|
|
proc.sendline(u'fuck')
|
2015-07-25 21:02:04 +03:00
|
|
|
assert proc.expect([TIMEOUT, u'echo test'])
|
|
|
|
assert proc.expect([TIMEOUT, u'test'])
|
2015-09-06 13:29:42 +03:00
|
|
|
|
|
|
|
|
|
|
|
def how_to_configure(proc, TIMEOUT):
|
|
|
|
proc.sendline(u'fuck')
|
2015-09-06 13:40:29 +03:00
|
|
|
assert proc.expect([TIMEOUT, u"alias isn't configured"])
|