1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-18 20:11:17 +00:00

Fix tests with python 2

This commit is contained in:
nvbn 2015-07-25 03:22:05 +03:00
parent 8d981cf9b6
commit 8498b970cc
6 changed files with 62 additions and 62 deletions

View File

@ -1,42 +1,42 @@
def with_confirmation(proc): def with_confirmation(proc):
"""Ensures that command can be fixed when confirmation enabled.""" """Ensures that command can be fixed when confirmation enabled."""
proc.sendline('mkdir -p ~/.thefuck') proc.sendline(u'mkdir -p ~/.thefuck')
proc.sendline('echo "require_confirmation = True" > ~/.thefuck/settings.py') proc.sendline(u'echo "require_confirmation = True" > ~/.thefuck/settings.py')
proc.sendline('ehco test') proc.sendline(u'ehco test')
proc.sendline('fuck') proc.sendline(u'fuck')
proc.expect('echo test') proc.expect(u'echo test')
proc.expect('enter') proc.expect(u'enter')
proc.expect_exact('ctrl+c') proc.expect_exact(u'ctrl+c')
proc.send('\n') proc.send('\n')
proc.expect('test') proc.expect(u'test')
def refuse_with_confirmation(proc): def refuse_with_confirmation(proc):
"""Ensures that fix can be refused when confirmation enabled.""" """Ensures that fix can be refused when confirmation enabled."""
proc.sendline('mkdir -p ~/.thefuck') proc.sendline(u'mkdir -p ~/.thefuck')
proc.sendline('echo "require_confirmation = True" > ~/.thefuck/settings.py') proc.sendline(u'echo "require_confirmation = True" > ~/.thefuck/settings.py')
proc.sendline('ehco test') proc.sendline(u'ehco test')
proc.sendline('fuck') proc.sendline(u'fuck')
proc.expect('echo test') proc.expect(u'echo test')
proc.expect('enter') proc.expect(u'enter')
proc.expect_exact('ctrl+c') proc.expect_exact(u'ctrl+c')
proc.send('\003') proc.send('\003')
proc.expect('Aborted') proc.expect(u'Aborted')
def without_confirmation(proc): def without_confirmation(proc):
"""Ensures that command can be fixed when confirmation disabled.""" """Ensures that command can be fixed when confirmation disabled."""
proc.sendline('mkdir -p ~/.thefuck') proc.sendline(u'mkdir -p ~/.thefuck')
proc.sendline('echo "require_confirmation = False" > ~/.thefuck/settings.py') proc.sendline(u'echo "require_confirmation = False" > ~/.thefuck/settings.py')
proc.sendline('ehco test') proc.sendline(u'ehco test')
proc.sendline('fuck') proc.sendline(u'fuck')
proc.expect('echo test') proc.expect(u'echo test')
proc.expect('test') proc.expect(u'test')

View File

@ -3,14 +3,14 @@ from tests.functional.plots import with_confirmation, without_confirmation, \
refuse_with_confirmation refuse_with_confirmation
from tests.functional.utils import spawn, functional, images from tests.functional.utils import spawn, functional, images
containers = images(('ubuntu-python3-bash', ''' containers = images(('ubuntu-python3-bash', u'''
FROM ubuntu:latest FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python3 python3-pip python3-dev RUN apt-get install -yy python3 python3-pip python3-dev
RUN pip3 install -U setuptools RUN pip3 install -U setuptools
RUN ln -s /usr/bin/pip3 /usr/bin/pip RUN ln -s /usr/bin/pip3 /usr/bin/pip
'''), '''),
('ubuntu-python2-bash', ''' ('ubuntu-python2-bash', u'''
FROM ubuntu:latest FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python python-pip python-dev RUN apt-get install -yy python python-pip python-dev
@ -21,22 +21,22 @@ RUN pip2 install -U pip setuptools
@functional @functional
@pytest.mark.parametrize('tag, dockerfile', containers) @pytest.mark.parametrize('tag, dockerfile', containers)
def test_with_confirmation(tag, dockerfile): def test_with_confirmation(tag, dockerfile):
with spawn(tag, dockerfile, 'bash') as proc: with spawn(tag, dockerfile, u'bash') as proc:
proc.sendline('eval $(thefuck-alias)') proc.sendline(u'eval $(thefuck-alias)')
with_confirmation(proc) with_confirmation(proc)
@functional @functional
@pytest.mark.parametrize('tag, dockerfile', containers) @pytest.mark.parametrize('tag, dockerfile', containers)
def test_refuse_with_confirmation(tag, dockerfile): def test_refuse_with_confirmation(tag, dockerfile):
with spawn(tag, dockerfile, 'bash') as proc: with spawn(tag, dockerfile, u'bash') as proc:
proc.sendline('eval $(thefuck-alias)') proc.sendline(u'eval $(thefuck-alias)')
refuse_with_confirmation(proc) refuse_with_confirmation(proc)
@functional @functional
@pytest.mark.parametrize('tag, dockerfile', containers) @pytest.mark.parametrize('tag, dockerfile', containers)
def test_without_confirmation(tag, dockerfile): def test_without_confirmation(tag, dockerfile):
with spawn(tag, dockerfile, 'bash') as proc: with spawn(tag, dockerfile, u'bash') as proc:
proc.sendline('eval $(thefuck-alias)') proc.sendline(u'eval $(thefuck-alias)')
without_confirmation(proc) without_confirmation(proc)

View File

@ -3,14 +3,14 @@ from tests.functional.plots import with_confirmation, without_confirmation, \
refuse_with_confirmation refuse_with_confirmation
from tests.functional.utils import spawn, functional, images from tests.functional.utils import spawn, functional, images
containers = images(('ubuntu-python3-fish', ''' containers = images(('ubuntu-python3-fish', u'''
FROM ubuntu:latest FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python3 python3-pip python3-dev fish RUN apt-get install -yy python3 python3-pip python3-dev fish
RUN pip3 install -U setuptools RUN pip3 install -U setuptools
RUN ln -s /usr/bin/pip3 /usr/bin/pip RUN ln -s /usr/bin/pip3 /usr/bin/pip
'''), '''),
('ubuntu-python2-fish', ''' ('ubuntu-python2-fish', u'''
FROM ubuntu:latest FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python python-pip python-dev fish RUN apt-get install -yy python python-pip python-dev fish
@ -21,25 +21,25 @@ RUN pip2 install -U pip setuptools
@functional @functional
@pytest.mark.parametrize('tag, dockerfile', containers) @pytest.mark.parametrize('tag, dockerfile', containers)
def test_with_confirmation(tag, dockerfile): def test_with_confirmation(tag, dockerfile):
with spawn(tag, dockerfile, 'fish') as proc: with spawn(tag, dockerfile, u'fish') as proc:
proc.sendline('thefuck-alias > ~/.config/fish/config.fish') proc.sendline(u'thefuck-alias > ~/.config/fish/config.fish')
proc.sendline('fish') proc.sendline(u'fish')
with_confirmation(proc) with_confirmation(proc)
@functional @functional
@pytest.mark.parametrize('tag, dockerfile', containers) @pytest.mark.parametrize('tag, dockerfile', containers)
def test_refuse_with_confirmation(tag, dockerfile): def test_refuse_with_confirmation(tag, dockerfile):
with spawn(tag, dockerfile, 'fish') as proc: with spawn(tag, dockerfile, u'fish') as proc:
proc.sendline('thefuck-alias > ~/.config/fish/config.fish') proc.sendline(u'thefuck-alias > ~/.config/fish/config.fish')
proc.sendline('fish') proc.sendline(u'fish')
refuse_with_confirmation(proc) refuse_with_confirmation(proc)
@functional @functional
@pytest.mark.parametrize('tag, dockerfile', containers) @pytest.mark.parametrize('tag, dockerfile', containers)
def test_without_confirmation(tag, dockerfile): def test_without_confirmation(tag, dockerfile):
with spawn(tag, dockerfile, 'fish') as proc: with spawn(tag, dockerfile, u'fish') as proc:
proc.sendline('thefuck-alias > ~/.config/fish/config.fish') proc.sendline(u'thefuck-alias > ~/.config/fish/config.fish')
proc.sendline('fish') proc.sendline(u'fish')
without_confirmation(proc) without_confirmation(proc)

View File

@ -3,14 +3,14 @@ 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 refuse_with_confirmation
containers = images(('ubuntu-python3-tcsh', ''' containers = images(('ubuntu-python3-tcsh', u'''
FROM ubuntu:latest FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python3 python3-pip python3-dev tcsh RUN apt-get install -yy python3 python3-pip python3-dev tcsh
RUN pip3 install -U setuptools RUN pip3 install -U setuptools
RUN ln -s /usr/bin/pip3 /usr/bin/pip RUN ln -s /usr/bin/pip3 /usr/bin/pip
'''), '''),
('ubuntu-python2-tcsh', ''' ('ubuntu-python2-tcsh', u'''
FROM ubuntu:latest FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python python-pip python-dev tcsh RUN apt-get install -yy python python-pip python-dev tcsh
@ -21,25 +21,25 @@ RUN pip2 install -U pip setuptools
@functional @functional
@pytest.mark.parametrize('tag, dockerfile', containers) @pytest.mark.parametrize('tag, dockerfile', containers)
def test_with_confirmation(tag, dockerfile): def test_with_confirmation(tag, dockerfile):
with spawn(tag, dockerfile, 'tcsh') as proc: with spawn(tag, dockerfile, u'tcsh') as proc:
proc.sendline('tcsh') proc.sendline(u'tcsh')
proc.sendline('eval `thefuck-alias`') proc.sendline(u'eval `thefuck-alias`')
with_confirmation(proc) with_confirmation(proc)
@functional @functional
@pytest.mark.parametrize('tag, dockerfile', containers) @pytest.mark.parametrize('tag, dockerfile', containers)
def test_refuse_with_confirmation(tag, dockerfile): def test_refuse_with_confirmation(tag, dockerfile):
with spawn(tag, dockerfile, 'tcsh') as proc: with spawn(tag, dockerfile, u'tcsh') as proc:
proc.sendline('tcsh') proc.sendline(u'tcsh')
proc.sendline('eval `thefuck-alias`') proc.sendline(u'eval `thefuck-alias`')
refuse_with_confirmation(proc) refuse_with_confirmation(proc)
@functional @functional
@pytest.mark.parametrize('tag, dockerfile', containers) @pytest.mark.parametrize('tag, dockerfile', containers)
def test_without_confirmation(tag, dockerfile): def test_without_confirmation(tag, dockerfile):
with spawn(tag, dockerfile, 'tcsh') as proc: with spawn(tag, dockerfile, u'tcsh') as proc:
proc.sendline('tcsh') proc.sendline(u'tcsh')
proc.sendline('eval `thefuck-alias`') proc.sendline(u'eval `thefuck-alias`')
without_confirmation(proc) without_confirmation(proc)

View File

@ -1,16 +1,16 @@
import pytest import pytest
from tests.functional.utils import spawn, functional, images 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 refuse_with_confirmation
containers = images(('ubuntu-python3-zsh', ''' containers = images(('ubuntu-python3-zsh', u'''
FROM ubuntu:latest FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python3 python3-pip python3-dev zsh RUN apt-get install -yy python3 python3-pip python3-dev zsh
RUN pip3 install -U setuptools RUN pip3 install -U setuptools
RUN ln -s /usr/bin/pip3 /usr/bin/pip RUN ln -s /usr/bin/pip3 /usr/bin/pip
'''), '''),
('ubuntu-python2-zsh', ''' ('ubuntu-python2-zsh', u'''
FROM ubuntu:latest FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python python-pip python-dev zsh RUN apt-get install -yy python python-pip python-dev zsh
@ -21,22 +21,22 @@ RUN pip2 install -U pip setuptools
@functional @functional
@pytest.mark.parametrize('tag, dockerfile', containers) @pytest.mark.parametrize('tag, dockerfile', containers)
def test_with_confirmation(tag, dockerfile): def test_with_confirmation(tag, dockerfile):
with spawn(tag, dockerfile, 'zsh') as proc: with spawn(tag, dockerfile, u'zsh') as proc:
proc.sendline('eval $(thefuck-alias)') proc.sendline(u'eval $(thefuck-alias)')
with_confirmation(proc) with_confirmation(proc)
@functional @functional
@pytest.mark.parametrize('tag, dockerfile', containers) @pytest.mark.parametrize('tag, dockerfile', containers)
def test_refuse_with_confirmation(tag, dockerfile): def test_refuse_with_confirmation(tag, dockerfile):
with spawn(tag, dockerfile, 'zsh') as proc: with spawn(tag, dockerfile, u'zsh') as proc:
proc.sendline('eval $(thefuck-alias)') proc.sendline(u'eval $(thefuck-alias)')
refuse_with_confirmation(proc) refuse_with_confirmation(proc)
@functional @functional
@pytest.mark.parametrize('tag, dockerfile', containers) @pytest.mark.parametrize('tag, dockerfile', containers)
def test_without_confirmation(tag, dockerfile): def test_without_confirmation(tag, dockerfile):
with spawn(tag, dockerfile, 'zsh') as proc: with spawn(tag, dockerfile, u'zsh') as proc:
proc.sendline('eval $(thefuck-alias)') proc.sendline(u'eval $(thefuck-alias)')
without_confirmation(proc) without_confirmation(proc)

View File

@ -3,4 +3,4 @@ envlist = py27,py33,py34
[testenv] [testenv]
deps = -rrequirements.txt deps = -rrequirements.txt
commands = py.test commands = py.test -v --capture=sys