From 8498b970ccbee1950b256baa751f7ee5e667e350 Mon Sep 17 00:00:00 2001 From: nvbn Date: Sat, 25 Jul 2015 03:22:05 +0300 Subject: [PATCH] Fix tests with python 2 --- tests/functional/plots.py | 44 +++++++++++++++++------------------ tests/functional/test_bash.py | 16 ++++++------- tests/functional/test_fish.py | 22 +++++++++--------- tests/functional/test_tcsh.py | 22 +++++++++--------- tests/functional/test_zsh.py | 18 +++++++------- tox.ini | 2 +- 6 files changed, 62 insertions(+), 62 deletions(-) diff --git a/tests/functional/plots.py b/tests/functional/plots.py index e541426c..54b9a4b1 100644 --- a/tests/functional/plots.py +++ b/tests/functional/plots.py @@ -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') diff --git a/tests/functional/test_bash.py b/tests/functional/test_bash.py index deb6f118..1aabf7ea 100644 --- a/tests/functional/test_bash.py +++ b/tests/functional/test_bash.py @@ -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) diff --git a/tests/functional/test_fish.py b/tests/functional/test_fish.py index f5faa5fe..090b183b 100644 --- a/tests/functional/test_fish.py +++ b/tests/functional/test_fish.py @@ -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) diff --git a/tests/functional/test_tcsh.py b/tests/functional/test_tcsh.py index 0ad13a2c..f56ee55e 100644 --- a/tests/functional/test_tcsh.py +++ b/tests/functional/test_tcsh.py @@ -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) diff --git a/tests/functional/test_zsh.py b/tests/functional/test_zsh.py index 71847518..44ed0153 100644 --- a/tests/functional/test_zsh.py +++ b/tests/functional/test_zsh.py @@ -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) diff --git a/tox.ini b/tox.ini index 46cf1c17..dfa75c02 100644 --- a/tox.ini +++ b/tox.ini @@ -3,4 +3,4 @@ envlist = py27,py33,py34 [testenv] deps = -rrequirements.txt -commands = py.test +commands = py.test -v --capture=sys