mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 12:06:04 +00:00
Fix tests with python 2
This commit is contained in:
parent
8d981cf9b6
commit
8498b970cc
@ -1,42 +1,42 @@
|
||||
def with_confirmation(proc):
|
||||
"""Ensures that command can be fixed when confirmation enabled."""
|
||||
proc.sendline('mkdir -p ~/.thefuck')
|
||||
proc.sendline('echo "require_confirmation = True" > ~/.thefuck/settings.py')
|
||||
proc.sendline(u'mkdir -p ~/.thefuck')
|
||||
proc.sendline(u'echo "require_confirmation = True" > ~/.thefuck/settings.py')
|
||||
|
||||
proc.sendline('ehco test')
|
||||
proc.sendline(u'ehco test')
|
||||
|
||||
proc.sendline('fuck')
|
||||
proc.expect('echo test')
|
||||
proc.expect('enter')
|
||||
proc.expect_exact('ctrl+c')
|
||||
proc.sendline(u'fuck')
|
||||
proc.expect(u'echo test')
|
||||
proc.expect(u'enter')
|
||||
proc.expect_exact(u'ctrl+c')
|
||||
proc.send('\n')
|
||||
|
||||
proc.expect('test')
|
||||
proc.expect(u'test')
|
||||
|
||||
|
||||
def refuse_with_confirmation(proc):
|
||||
"""Ensures that fix can be refused when confirmation enabled."""
|
||||
proc.sendline('mkdir -p ~/.thefuck')
|
||||
proc.sendline('echo "require_confirmation = True" > ~/.thefuck/settings.py')
|
||||
proc.sendline(u'mkdir -p ~/.thefuck')
|
||||
proc.sendline(u'echo "require_confirmation = True" > ~/.thefuck/settings.py')
|
||||
|
||||
proc.sendline('ehco test')
|
||||
proc.sendline(u'ehco test')
|
||||
|
||||
proc.sendline('fuck')
|
||||
proc.expect('echo test')
|
||||
proc.expect('enter')
|
||||
proc.expect_exact('ctrl+c')
|
||||
proc.sendline(u'fuck')
|
||||
proc.expect(u'echo test')
|
||||
proc.expect(u'enter')
|
||||
proc.expect_exact(u'ctrl+c')
|
||||
proc.send('\003')
|
||||
|
||||
proc.expect('Aborted')
|
||||
proc.expect(u'Aborted')
|
||||
|
||||
|
||||
def without_confirmation(proc):
|
||||
"""Ensures that command can be fixed when confirmation disabled."""
|
||||
proc.sendline('mkdir -p ~/.thefuck')
|
||||
proc.sendline('echo "require_confirmation = False" > ~/.thefuck/settings.py')
|
||||
proc.sendline(u'mkdir -p ~/.thefuck')
|
||||
proc.sendline(u'echo "require_confirmation = False" > ~/.thefuck/settings.py')
|
||||
|
||||
proc.sendline('ehco test')
|
||||
proc.sendline(u'ehco test')
|
||||
|
||||
proc.sendline('fuck')
|
||||
proc.expect('echo test')
|
||||
proc.expect('test')
|
||||
proc.sendline(u'fuck')
|
||||
proc.expect(u'echo test')
|
||||
proc.expect(u'test')
|
||||
|
@ -3,14 +3,14 @@ from tests.functional.plots import with_confirmation, without_confirmation, \
|
||||
refuse_with_confirmation
|
||||
from tests.functional.utils import spawn, functional, images
|
||||
|
||||
containers = images(('ubuntu-python3-bash', '''
|
||||
containers = images(('ubuntu-python3-bash', u'''
|
||||
FROM ubuntu:latest
|
||||
RUN apt-get update
|
||||
RUN apt-get install -yy python3 python3-pip python3-dev
|
||||
RUN pip3 install -U setuptools
|
||||
RUN ln -s /usr/bin/pip3 /usr/bin/pip
|
||||
'''),
|
||||
('ubuntu-python2-bash', '''
|
||||
('ubuntu-python2-bash', u'''
|
||||
FROM ubuntu:latest
|
||||
RUN apt-get update
|
||||
RUN apt-get install -yy python python-pip python-dev
|
||||
@ -21,22 +21,22 @@ RUN pip2 install -U pip setuptools
|
||||
@functional
|
||||
@pytest.mark.parametrize('tag, dockerfile', containers)
|
||||
def test_with_confirmation(tag, dockerfile):
|
||||
with spawn(tag, dockerfile, 'bash') as proc:
|
||||
proc.sendline('eval $(thefuck-alias)')
|
||||
with spawn(tag, dockerfile, u'bash') as proc:
|
||||
proc.sendline(u'eval $(thefuck-alias)')
|
||||
with_confirmation(proc)
|
||||
|
||||
|
||||
@functional
|
||||
@pytest.mark.parametrize('tag, dockerfile', containers)
|
||||
def test_refuse_with_confirmation(tag, dockerfile):
|
||||
with spawn(tag, dockerfile, 'bash') as proc:
|
||||
proc.sendline('eval $(thefuck-alias)')
|
||||
with spawn(tag, dockerfile, u'bash') as proc:
|
||||
proc.sendline(u'eval $(thefuck-alias)')
|
||||
refuse_with_confirmation(proc)
|
||||
|
||||
|
||||
@functional
|
||||
@pytest.mark.parametrize('tag, dockerfile', containers)
|
||||
def test_without_confirmation(tag, dockerfile):
|
||||
with spawn(tag, dockerfile, 'bash') as proc:
|
||||
proc.sendline('eval $(thefuck-alias)')
|
||||
with spawn(tag, dockerfile, u'bash') as proc:
|
||||
proc.sendline(u'eval $(thefuck-alias)')
|
||||
without_confirmation(proc)
|
||||
|
@ -3,14 +3,14 @@ from tests.functional.plots import with_confirmation, without_confirmation, \
|
||||
refuse_with_confirmation
|
||||
from tests.functional.utils import spawn, functional, images
|
||||
|
||||
containers = images(('ubuntu-python3-fish', '''
|
||||
containers = images(('ubuntu-python3-fish', u'''
|
||||
FROM ubuntu:latest
|
||||
RUN apt-get update
|
||||
RUN apt-get install -yy python3 python3-pip python3-dev fish
|
||||
RUN pip3 install -U setuptools
|
||||
RUN ln -s /usr/bin/pip3 /usr/bin/pip
|
||||
'''),
|
||||
('ubuntu-python2-fish', '''
|
||||
('ubuntu-python2-fish', u'''
|
||||
FROM ubuntu:latest
|
||||
RUN apt-get update
|
||||
RUN apt-get install -yy python python-pip python-dev fish
|
||||
@ -21,25 +21,25 @@ RUN pip2 install -U pip setuptools
|
||||
@functional
|
||||
@pytest.mark.parametrize('tag, dockerfile', containers)
|
||||
def test_with_confirmation(tag, dockerfile):
|
||||
with spawn(tag, dockerfile, 'fish') as proc:
|
||||
proc.sendline('thefuck-alias > ~/.config/fish/config.fish')
|
||||
proc.sendline('fish')
|
||||
with spawn(tag, dockerfile, u'fish') as proc:
|
||||
proc.sendline(u'thefuck-alias > ~/.config/fish/config.fish')
|
||||
proc.sendline(u'fish')
|
||||
with_confirmation(proc)
|
||||
|
||||
|
||||
@functional
|
||||
@pytest.mark.parametrize('tag, dockerfile', containers)
|
||||
def test_refuse_with_confirmation(tag, dockerfile):
|
||||
with spawn(tag, dockerfile, 'fish') as proc:
|
||||
proc.sendline('thefuck-alias > ~/.config/fish/config.fish')
|
||||
proc.sendline('fish')
|
||||
with spawn(tag, dockerfile, u'fish') as proc:
|
||||
proc.sendline(u'thefuck-alias > ~/.config/fish/config.fish')
|
||||
proc.sendline(u'fish')
|
||||
refuse_with_confirmation(proc)
|
||||
|
||||
|
||||
@functional
|
||||
@pytest.mark.parametrize('tag, dockerfile', containers)
|
||||
def test_without_confirmation(tag, dockerfile):
|
||||
with spawn(tag, dockerfile, 'fish') as proc:
|
||||
proc.sendline('thefuck-alias > ~/.config/fish/config.fish')
|
||||
proc.sendline('fish')
|
||||
with spawn(tag, dockerfile, u'fish') as proc:
|
||||
proc.sendline(u'thefuck-alias > ~/.config/fish/config.fish')
|
||||
proc.sendline(u'fish')
|
||||
without_confirmation(proc)
|
||||
|
@ -3,14 +3,14 @@ from tests.functional.utils import spawn, functional, images
|
||||
from tests.functional.plots import with_confirmation, without_confirmation, \
|
||||
refuse_with_confirmation
|
||||
|
||||
containers = images(('ubuntu-python3-tcsh', '''
|
||||
containers = images(('ubuntu-python3-tcsh', u'''
|
||||
FROM ubuntu:latest
|
||||
RUN apt-get update
|
||||
RUN apt-get install -yy python3 python3-pip python3-dev tcsh
|
||||
RUN pip3 install -U setuptools
|
||||
RUN ln -s /usr/bin/pip3 /usr/bin/pip
|
||||
'''),
|
||||
('ubuntu-python2-tcsh', '''
|
||||
('ubuntu-python2-tcsh', u'''
|
||||
FROM ubuntu:latest
|
||||
RUN apt-get update
|
||||
RUN apt-get install -yy python python-pip python-dev tcsh
|
||||
@ -21,25 +21,25 @@ RUN pip2 install -U pip setuptools
|
||||
@functional
|
||||
@pytest.mark.parametrize('tag, dockerfile', containers)
|
||||
def test_with_confirmation(tag, dockerfile):
|
||||
with spawn(tag, dockerfile, 'tcsh') as proc:
|
||||
proc.sendline('tcsh')
|
||||
proc.sendline('eval `thefuck-alias`')
|
||||
with spawn(tag, dockerfile, u'tcsh') as proc:
|
||||
proc.sendline(u'tcsh')
|
||||
proc.sendline(u'eval `thefuck-alias`')
|
||||
with_confirmation(proc)
|
||||
|
||||
|
||||
@functional
|
||||
@pytest.mark.parametrize('tag, dockerfile', containers)
|
||||
def test_refuse_with_confirmation(tag, dockerfile):
|
||||
with spawn(tag, dockerfile, 'tcsh') as proc:
|
||||
proc.sendline('tcsh')
|
||||
proc.sendline('eval `thefuck-alias`')
|
||||
with spawn(tag, dockerfile, u'tcsh') as proc:
|
||||
proc.sendline(u'tcsh')
|
||||
proc.sendline(u'eval `thefuck-alias`')
|
||||
refuse_with_confirmation(proc)
|
||||
|
||||
|
||||
@functional
|
||||
@pytest.mark.parametrize('tag, dockerfile', containers)
|
||||
def test_without_confirmation(tag, dockerfile):
|
||||
with spawn(tag, dockerfile, 'tcsh') as proc:
|
||||
proc.sendline('tcsh')
|
||||
proc.sendline('eval `thefuck-alias`')
|
||||
with spawn(tag, dockerfile, u'tcsh') as proc:
|
||||
proc.sendline(u'tcsh')
|
||||
proc.sendline(u'eval `thefuck-alias`')
|
||||
without_confirmation(proc)
|
||||
|
@ -1,16 +1,16 @@
|
||||
import pytest
|
||||
from tests.functional.utils import spawn, functional, images
|
||||
from tests.functional.plots import with_confirmation, without_confirmation,\
|
||||
from tests.functional.plots import with_confirmation, without_confirmation, \
|
||||
refuse_with_confirmation
|
||||
|
||||
containers = images(('ubuntu-python3-zsh', '''
|
||||
containers = images(('ubuntu-python3-zsh', u'''
|
||||
FROM ubuntu:latest
|
||||
RUN apt-get update
|
||||
RUN apt-get install -yy python3 python3-pip python3-dev zsh
|
||||
RUN pip3 install -U setuptools
|
||||
RUN ln -s /usr/bin/pip3 /usr/bin/pip
|
||||
'''),
|
||||
('ubuntu-python2-zsh', '''
|
||||
('ubuntu-python2-zsh', u'''
|
||||
FROM ubuntu:latest
|
||||
RUN apt-get update
|
||||
RUN apt-get install -yy python python-pip python-dev zsh
|
||||
@ -21,22 +21,22 @@ RUN pip2 install -U pip setuptools
|
||||
@functional
|
||||
@pytest.mark.parametrize('tag, dockerfile', containers)
|
||||
def test_with_confirmation(tag, dockerfile):
|
||||
with spawn(tag, dockerfile, 'zsh') as proc:
|
||||
proc.sendline('eval $(thefuck-alias)')
|
||||
with spawn(tag, dockerfile, u'zsh') as proc:
|
||||
proc.sendline(u'eval $(thefuck-alias)')
|
||||
with_confirmation(proc)
|
||||
|
||||
|
||||
@functional
|
||||
@pytest.mark.parametrize('tag, dockerfile', containers)
|
||||
def test_refuse_with_confirmation(tag, dockerfile):
|
||||
with spawn(tag, dockerfile, 'zsh') as proc:
|
||||
proc.sendline('eval $(thefuck-alias)')
|
||||
with spawn(tag, dockerfile, u'zsh') as proc:
|
||||
proc.sendline(u'eval $(thefuck-alias)')
|
||||
refuse_with_confirmation(proc)
|
||||
|
||||
|
||||
@functional
|
||||
@pytest.mark.parametrize('tag, dockerfile', containers)
|
||||
def test_without_confirmation(tag, dockerfile):
|
||||
with spawn(tag, dockerfile, 'zsh') as proc:
|
||||
proc.sendline('eval $(thefuck-alias)')
|
||||
with spawn(tag, dockerfile, u'zsh') as proc:
|
||||
proc.sendline(u'eval $(thefuck-alias)')
|
||||
without_confirmation(proc)
|
||||
|
Loading…
Reference in New Issue
Block a user