1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-09-20 20:22:41 +01:00

#N/A Simplify functional tests

This commit is contained in:
nvbn
2015-07-24 07:38:45 +03:00
parent 7906025cc6
commit c34a56bc89
3 changed files with 50 additions and 66 deletions

View File

@@ -1,6 +1,5 @@
import pytest
from tests.functional.utils import build_container, spawn, run, read_until, \
root, functional
from tests.functional.utils import spawn, functional
containers = [('thefuck/ubuntu-python3-zsh', '''
FROM ubuntu:latest
@@ -8,7 +7,6 @@ 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
RUN echo "PS1='\\n$ '" > /root/.zshrc
CMD ["/bin/zsh"]
'''),
('thefuck/ubuntu-python2-zsh', '''
@@ -16,7 +14,6 @@ FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -yy python python-pip python-dev zsh
RUN pip2 install -U pip setuptools
RUN echo "PS1='\\n$ '" > /root/.zshrc
CMD ["/bin/zsh"]
''')]
@@ -24,27 +21,31 @@ CMD ["/bin/zsh"]
@functional
@pytest.mark.parametrize('tag, dockerfile', containers)
def test_with_confirmation(tag, dockerfile):
build_container(tag, dockerfile)
with spawn(tag, '{}:/src'.format(root),
['cd /src', 'pip install .', 'eval $(thefuck-alias)']) as proc:
run(proc, 'ehco "\ntest"')
with spawn(tag, dockerfile) as proc:
proc.sendline('eval $(thefuck-alias)')
proc.sendline('ehco test')
proc.expect('command not found')
proc.sendline('fuck')
read_until(proc, '[')
proc.expect('echo test')
proc.expect('enter')
proc.expect_exact('ctrl+c')
proc.send('\n')
read_until(proc)
out = read_until(proc)
assert out.split('\n')[-3] == 'test\r\r'
proc.expect('test')
@functional
@pytest.mark.parametrize('tag, dockerfile', containers)
def test_without_confirmation(tag, dockerfile):
build_container(tag, dockerfile)
with spawn(tag, '{}:/src'.format(root),
['cd /src', 'pip install .',
'export THEFUCK_REQUIRE_CONFIRMATION=false',
'eval $(thefuck-alias)']) as proc:
run(proc, 'ehco "\ntest"')
run(proc, 'fuck')
out = read_until(proc)
assert out.split('\n')[-3] == 'test\r\r'
with spawn(tag, dockerfile) as proc:
proc.sendline('export THEFUCK_REQUIRE_CONFIRMATION=false')
proc.sendline('eval $(thefuck-alias)')
proc.sendline('ehco test')
proc.expect('command not found')
proc.sendline('fuck')
proc.expect('echo test')
proc.expect('test')