1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-02-21 20:38:54 +00:00

Merge pull request #359 from nvbn/use-pytest-docker-pexpect

Use pytest-docker-pexpect
This commit is contained in:
Vladimir Iakovlev 2015-09-06 01:28:37 +03:00
commit 4ae2e9bbc4
13 changed files with 196 additions and 245 deletions

View File

@ -1,4 +1,5 @@
language: python language: python
sudo: false
python: python:
- "3.4" - "3.4"
- "3.3" - "3.3"
@ -14,8 +15,6 @@ addons:
- tcsh - tcsh
- pandoc - pandoc
- git - git
env:
- FUNCTIONAL=true BARE=true
install: install:
- pip install coveralls - pip install coveralls
- pip install -r requirements.txt - pip install -r requirements.txt
@ -23,5 +22,5 @@ install:
- rm -rf build - rm -rf build
script: script:
- export COVERAGE_PYTHON_VERSION=python-${TRAVIS_PYTHON_VERSION:0:1} - export COVERAGE_PYTHON_VERSION=python-${TRAVIS_PYTHON_VERSION:0:1}
- coverage run --source=thefuck,tests -m py.test -v --capture=sys - coverage run --source=thefuck,tests -m py.test -v --capture=sys --run-without-docker --enable-functional
after_success: coveralls after_success: coveralls

View File

@ -326,7 +326,7 @@ py.test
Run unit and functional tests (requires docker): Run unit and functional tests (requires docker):
```bash ```bash
FUNCTIONAL=true py.test py.test --enable-functional
``` ```
For sending package to pypi: For sending package to pypi:

View File

@ -6,3 +6,4 @@ setuptools>=17.1
pexpect pexpect
pypandoc pypandoc
pytest-benchmark pytest-benchmark
pytest-docker-pexpect

View File

@ -2,6 +2,13 @@ import pytest
from mock import Mock from mock import Mock
def pytest_addoption(parser):
"""Adds `--run-without-docker` argument."""
group = parser.getgroup("thefuck")
group.addoption('--enable-functional', action="store_true", default=False,
help="Enable functional tests")
@pytest.fixture @pytest.fixture
def no_memoize(monkeypatch): def no_memoize(monkeypatch):
monkeypatch.setattr('thefuck.utils.memoize.disabled', True) monkeypatch.setattr('thefuck.utils.memoize.disabled', True)
@ -15,3 +22,10 @@ def settings():
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def no_cache(monkeypatch): def no_cache(monkeypatch):
monkeypatch.setattr('thefuck.utils.cache.disabled', True) monkeypatch.setattr('thefuck.utils.cache.disabled', True)
@pytest.fixture(autouse=True)
def functional(request):
if request.node.get_marker('functional') \
and not request.config.getoption('enable_functional'):
pytest.skip('functional tests are disabled')

View File

@ -1,6 +1,3 @@
from pexpect import TIMEOUT
def _set_confirmation(proc, require): def _set_confirmation(proc, require):
proc.sendline(u'mkdir -p ~/.thefuck') proc.sendline(u'mkdir -p ~/.thefuck')
proc.sendline( proc.sendline(
@ -8,7 +5,7 @@ def _set_confirmation(proc, require):
require)) require))
def with_confirmation(proc): def with_confirmation(proc, TIMEOUT):
"""Ensures that command can be fixed when confirmation enabled.""" """Ensures that command can be fixed when confirmation enabled."""
_set_confirmation(proc, True) _set_confirmation(proc, True)
@ -23,19 +20,19 @@ def with_confirmation(proc):
assert proc.expect([TIMEOUT, u'test']) assert proc.expect([TIMEOUT, u'test'])
def history_changed(proc, to): def history_changed(proc, TIMEOUT, to):
"""Ensures that history changed.""" """Ensures that history changed."""
proc.send('\033[A') proc.send('\033[A')
assert proc.expect([TIMEOUT, to]) assert proc.expect([TIMEOUT, to])
def history_not_changed(proc): def history_not_changed(proc, TIMEOUT):
"""Ensures that history not changed.""" """Ensures that history not changed."""
proc.send('\033[A') proc.send('\033[A')
assert proc.expect([TIMEOUT, u'fuck']) assert proc.expect([TIMEOUT, u'fuck'])
def select_command_with_arrows(proc): def select_command_with_arrows(proc, TIMEOUT):
"""Ensures that command can be selected with arrow keys.""" """Ensures that command can be selected with arrow keys."""
_set_confirmation(proc, True) _set_confirmation(proc, True)
@ -50,12 +47,14 @@ def select_command_with_arrows(proc):
assert proc.expect([TIMEOUT, u'git help']) assert proc.expect([TIMEOUT, u'git help'])
proc.send('\033[A') proc.send('\033[A')
assert proc.expect([TIMEOUT, u'git push']) assert proc.expect([TIMEOUT, u'git push'])
proc.send('\033[B')
assert proc.expect([TIMEOUT, u'git help'])
proc.send('\n') proc.send('\n')
assert proc.expect([TIMEOUT, u'Not a git repository']) assert proc.expect([TIMEOUT, u'usage'])
def refuse_with_confirmation(proc): def refuse_with_confirmation(proc, TIMEOUT):
"""Ensures that fix can be refused when confirmation enabled.""" """Ensures that fix can be refused when confirmation enabled."""
_set_confirmation(proc, True) _set_confirmation(proc, True)
@ -70,7 +69,7 @@ def refuse_with_confirmation(proc):
assert proc.expect([TIMEOUT, u'Aborted']) assert proc.expect([TIMEOUT, u'Aborted'])
def without_confirmation(proc): def without_confirmation(proc, TIMEOUT):
"""Ensures that command can be fixed when confirmation disabled.""" """Ensures that command can be fixed when confirmation disabled."""
_set_confirmation(proc, False) _set_confirmation(proc, False)

View File

@ -2,52 +2,56 @@ import pytest
from tests.functional.plots import with_confirmation, without_confirmation, \ from tests.functional.plots import with_confirmation, without_confirmation, \
refuse_with_confirmation, history_changed, history_not_changed, \ refuse_with_confirmation, history_changed, history_not_changed, \
select_command_with_arrows select_command_with_arrows
from tests.functional.utils import spawn, functional, images
containers = images(('ubuntu-python3-bash', u''' containers = ((u'thefuck/ubuntu-python3-bash',
FROM ubuntu:latest u'''FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python3 python3-pip python3-dev git RUN apt-get install -yy python3 python3-pip python3-dev git
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''',
'''), u'bash'),
('ubuntu-python2-bash', u''' (u'thefuck/ubuntu-python2-bash',
FROM ubuntu:latest u'''FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python python-pip python-dev git RUN apt-get install -yy python python-pip python-dev git
RUN pip2 install -U pip setuptools RUN pip2 install -U pip setuptools''',
''')) u'bash'))
@pytest.fixture(params=containers) @pytest.fixture(params=containers)
def proc(request): def proc(request, spawnu, run_without_docker):
tag, dockerfile = request.param proc = spawnu(*request.param)
proc = spawn(request, tag, dockerfile, u'bash') if not run_without_docker:
proc.sendline(u"pip install /src")
proc.sendline(u"export PS1='$ '") proc.sendline(u"export PS1='$ '")
proc.sendline(u'eval $(thefuck --alias)') proc.sendline(u'eval $(thefuck --alias)')
proc.sendline(u'echo > $HISTFILE') proc.sendline(u'echo > $HISTFILE')
return proc return proc
@functional @pytest.mark.functional
def test_with_confirmation(proc): @pytest.mark.once_without_docker
with_confirmation(proc) def test_with_confirmation(proc, TIMEOUT):
history_changed(proc, u'echo test') with_confirmation(proc, TIMEOUT)
history_changed(proc, TIMEOUT, u'echo test')
@functional @pytest.mark.functional
def test_select_command_with_arrows(proc): @pytest.mark.once_without_docker
select_command_with_arrows(proc) def test_select_command_with_arrows(proc, TIMEOUT):
history_changed(proc, u'git push') select_command_with_arrows(proc, TIMEOUT)
history_changed(proc, TIMEOUT, u'git help')
@functional @pytest.mark.functional
def test_refuse_with_confirmation(proc): @pytest.mark.once_without_docker
refuse_with_confirmation(proc) def test_refuse_with_confirmation(proc, TIMEOUT):
history_not_changed(proc) refuse_with_confirmation(proc, TIMEOUT)
history_not_changed(proc, TIMEOUT)
@functional @pytest.mark.functional
def test_without_confirmation(proc): @pytest.mark.once_without_docker
without_confirmation(proc) def test_without_confirmation(proc, TIMEOUT):
history_changed(proc, u'echo test') without_confirmation(proc, TIMEOUT)
history_changed(proc, TIMEOUT, u'echo test')

View File

@ -1,59 +1,54 @@
import pytest import pytest
from tests.functional.plots import with_confirmation, without_confirmation, \ from tests.functional.plots import with_confirmation, without_confirmation, \
refuse_with_confirmation, select_command_with_arrows refuse_with_confirmation, select_command_with_arrows
from tests.functional.utils import spawn, functional, images, bare
containers = images(('ubuntu-python3-fish', u''' containers = (('thefuck/ubuntu-python3-fish',
FROM ubuntu:latest u'''FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python3 python3-pip python3-dev fish git RUN apt-get install -yy python3 python3-pip python3-dev fish git
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
RUN apt-get install -yy fish RUN apt-get install -yy fish''',
'''), u'fish'),
('ubuntu-python2-fish', u''' ('thefuck/ubuntu-python2-fish',
FROM ubuntu:latest u'''FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python python-pip python-dev git RUN apt-get install -yy python python-pip python-dev git
RUN pip2 install -U pip setuptools RUN pip2 install -U pip setuptools
RUN apt-get install -yy fish RUN apt-get install -yy fish''',
''')) u'fish'))
@pytest.fixture(params=containers) @pytest.fixture(params=containers)
def proc(request): def proc(request, spawnu):
tag, dockerfile = request.param proc = spawnu(*request.param)
proc = spawn(request, tag, dockerfile, u'fish') proc.sendline(u"pip install /src")
proc.sendline(u'thefuck --alias > ~/.config/fish/config.fish') proc.sendline(u'thefuck --alias > ~/.config/fish/config.fish')
proc.sendline(u'fish') proc.sendline(u'fish')
return proc return proc
@functional @pytest.mark.functional
@pytest.mark.skipif( @pytest.mark.skip_without_docker
bool(bare), reason='https://github.com/travis-ci/apt-source-whitelist/issues/71') def test_with_confirmation(proc, TIMEOUT):
def test_with_confirmation(proc): with_confirmation(proc, TIMEOUT)
with_confirmation(proc)
@functional @pytest.mark.functional
@pytest.mark.skipif( @pytest.mark.skip_without_docker
bool(bare), reason='https://github.com/travis-ci/apt-source-whitelist/issues/71') def test_select_command_with_arrows(proc, TIMEOUT):
def test_select_command_with_arrows(proc): select_command_with_arrows(proc, TIMEOUT)
select_command_with_arrows(proc)
@functional @pytest.mark.functional
@pytest.mark.skipif( @pytest.mark.skip_without_docker
bool(bare), reason='https://github.com/travis-ci/apt-source-whitelist/issues/71') def test_refuse_with_confirmation(proc, TIMEOUT):
def test_refuse_with_confirmation(proc): refuse_with_confirmation(proc, TIMEOUT)
refuse_with_confirmation(proc)
@functional @pytest.mark.functional
@pytest.mark.skipif( @pytest.mark.skip_without_docker
bool(bare), reason='https://github.com/travis-ci/apt-source-whitelist/issues/71') def test_without_confirmation(proc, TIMEOUT):
def test_without_confirmation(proc): without_confirmation(proc, TIMEOUT)
without_confirmation(proc)
# TODO: ensure that history changes. # TODO: ensure that history changes.

View File

@ -1,25 +1,24 @@
import pytest import pytest
from pexpect import TIMEOUT from thefuck.main import _get_current_version
from tests.functional.utils import spawn, functional, bare
envs = ((u'bash', 'ubuntu-bash', u''' envs = ((u'bash', 'thefuck/ubuntu-bash', u'''
FROM ubuntu:latest FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy bash RUN apt-get install -yy bash
'''), (u'bash', 'generic-bash', u''' '''), (u'bash', 'thefuck/generic-bash', u'''
FROM fedora:latest FROM fedora:latest
RUN dnf install -yy python-devel sudo wget gcc RUN dnf install -yy python-devel sudo wget gcc
''')) '''))
@functional @pytest.mark.functional
@pytest.mark.skipif( @pytest.mark.skip_without_docker
bool(bare), reason="Can't be tested in bare run")
@pytest.mark.parametrize('shell, tag, dockerfile', envs) @pytest.mark.parametrize('shell, tag, dockerfile', envs)
def test_installation(request, shell, tag, dockerfile): def test_installation(spawnu, shell, TIMEOUT, tag, dockerfile):
proc = spawn(request, tag, dockerfile, shell, install=False) proc = spawnu(tag, dockerfile, shell)
proc.sendline(u'cat /src/install.sh | sh - && $0') proc.sendline(u'cat /src/install.sh | sh - && $0')
proc.sendline(u'thefuck --version') proc.sendline(u'thefuck --version')
assert proc.expect([TIMEOUT, u'The Fuck'], timeout=600) assert proc.expect([TIMEOUT, u'thefuck {}'.format(_get_current_version())],
timeout=600)
proc.sendline(u'fuck') proc.sendline(u'fuck')
assert proc.expect([TIMEOUT, u'No fucks given']) assert proc.expect([TIMEOUT, u'No fucks given'])

View File

@ -1,7 +1,5 @@
from pexpect import TIMEOUT
import pytest import pytest
import time import time
from tests.functional.utils import spawn, functional, bare
dockerfile = u''' dockerfile = u'''
FROM ubuntu:latest FROM ubuntu:latest
@ -11,24 +9,17 @@ RUN pip3 install -U setuptools
RUN ln -s /usr/bin/pip3 /usr/bin/pip RUN ln -s /usr/bin/pip3 /usr/bin/pip
RUN adduser --disabled-password --gecos '' test RUN adduser --disabled-password --gecos '' test
ENV SEED "{seed}" ENV SEED "{seed}"
COPY thefuck /src
WORKDIR /src WORKDIR /src
RUN pip install .
USER test USER test
RUN echo 'eval $(thefuck --alias)' > /home/test/.bashrc RUN echo 'eval $(thefuck --alias)' > /home/test/.bashrc
RUN echo > /home/test/.bash_history RUN echo > /home/test/.bash_history
RUN git config --global user.email "you@example.com" RUN git config --global user.email "you@example.com"
RUN git config --global user.name "Your Name" RUN git config --global user.name "Your Name"
USER root
'''.format(seed=time.time()) '''.format(seed=time.time())
@pytest.fixture def plot(proc, TIMEOUT):
def proc(request):
return spawn(request, 'ubuntu-python3-bash-performance',
dockerfile, u'bash', install=False, copy_src=True)
def plot(proc):
proc.sendline(u'cd /home/test/') proc.sendline(u'cd /home/test/')
proc.sendline(u'fuck') proc.sendline(u'fuck')
assert proc.expect([TIMEOUT, u'No fucks given']) assert proc.expect([TIMEOUT, u'No fucks given'])
@ -48,9 +39,12 @@ def plot(proc):
assert proc.expect([TIMEOUT, u'test']) assert proc.expect([TIMEOUT, u'test'])
@functional @pytest.mark.functional
@pytest.mark.skipif( @pytest.mark.skip_without_docker
bool(bare), reason='Would lie on a bare run')
@pytest.mark.benchmark(min_rounds=10) @pytest.mark.benchmark(min_rounds=10)
def test_performance(proc, benchmark): def test_performance(spawnu, TIMEOUT, benchmark):
assert benchmark(plot, proc) is None proc = spawnu(u'thefuck/ubuntu-python3-bash-performance',
dockerfile, u'bash')
proc.sendline(u'pip install /src')
proc.sendline(u'su test')
assert benchmark(plot, proc, TIMEOUT) is None

View File

@ -1,51 +1,55 @@
import pytest 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, select_command_with_arrows refuse_with_confirmation, select_command_with_arrows
containers = images(('ubuntu-python3-tcsh', u''' containers = (('thefuck/ubuntu-python3-tcsh',
FROM ubuntu:latest u'''FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python3 python3-pip python3-dev git RUN apt-get install -yy python3 python3-pip python3-dev git
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
RUN apt-get install -yy tcsh RUN apt-get install -yy tcsh''',
'''), u'tcsh'),
('ubuntu-python2-tcsh', u''' ('thefuck/ubuntu-python2-tcsh',
FROM ubuntu:latest u'''FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python python-pip python-dev git RUN apt-get install -yy python python-pip python-dev git
RUN pip2 install -U pip setuptools RUN pip2 install -U pip setuptools
RUN apt-get install -yy tcsh RUN apt-get install -yy tcsh''',
''')) u'tcsh'))
@pytest.fixture(params=containers) @pytest.fixture(params=containers)
def proc(request): def proc(request, spawnu, run_without_docker):
tag, dockerfile = request.param proc = spawnu(*request.param)
proc = spawn(request, tag, dockerfile, u'tcsh') if not run_without_docker:
proc.sendline(u'pip install /src')
proc.sendline(u'tcsh') proc.sendline(u'tcsh')
proc.sendline(u'eval `thefuck --alias`') proc.sendline(u'eval `thefuck --alias`')
return proc return proc
@functional @pytest.mark.functional
def test_with_confirmation(proc): @pytest.mark.once_without_docker
with_confirmation(proc) def test_with_confirmation(proc, TIMEOUT):
with_confirmation(proc, TIMEOUT)
@functional @pytest.mark.functional
def test_select_command_with_arrows(proc): @pytest.mark.once_without_docker
select_command_with_arrows(proc) def test_select_command_with_arrows(proc, TIMEOUT):
select_command_with_arrows(proc, TIMEOUT)
@functional @pytest.mark.functional
def test_refuse_with_confirmation(proc): @pytest.mark.once_without_docker
refuse_with_confirmation(proc) def test_refuse_with_confirmation(proc, TIMEOUT):
refuse_with_confirmation(proc, TIMEOUT)
@functional @pytest.mark.functional
def test_without_confirmation(proc): @pytest.mark.once_without_docker
without_confirmation(proc) def test_without_confirmation(proc, TIMEOUT):
without_confirmation(proc, TIMEOUT)
# TODO: ensure that history changes. # TODO: ensure that history changes.

View File

@ -1,29 +1,29 @@
import pytest 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, history_changed, history_not_changed, select_command_with_arrows refuse_with_confirmation, history_changed, history_not_changed, select_command_with_arrows
containers = images(('ubuntu-python3-zsh', u''' containers = (('ubuntu-python3-zsh',
FROM ubuntu:latest u'''FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python3 python3-pip python3-dev git RUN apt-get install -yy python3 python3-pip python3-dev git
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
RUN apt-get install -yy zsh RUN apt-get install -yy zsh''',
'''), u'zsh'),
('ubuntu-python2-zsh', u''' ('ubuntu-python2-zsh',
FROM ubuntu:latest u'''FROM ubuntu:latest
RUN apt-get update RUN apt-get update
RUN apt-get install -yy python python-pip python-dev git RUN apt-get install -yy python python-pip python-dev git
RUN pip2 install -U pip setuptools RUN pip2 install -U pip setuptools
RUN apt-get install -yy zsh RUN apt-get install -yy zsh''',
''')) u'zsh'))
@pytest.fixture(params=containers) @pytest.fixture(params=containers)
def proc(request): def proc(request, spawnu, run_without_docker):
tag, dockerfile = request.param proc = spawnu(*request.param)
proc = spawn(request, tag, dockerfile, u'zsh') if not run_without_docker:
proc.sendline(u'pip install /src')
proc.sendline(u'eval $(thefuck --alias)') proc.sendline(u'eval $(thefuck --alias)')
proc.sendline(u'export HISTFILE=~/.zsh_history') proc.sendline(u'export HISTFILE=~/.zsh_history')
proc.sendline(u'echo > $HISTFILE') proc.sendline(u'echo > $HISTFILE')
@ -33,25 +33,29 @@ def proc(request):
return proc return proc
@functional @pytest.mark.functional
def test_with_confirmation(proc): @pytest.mark.once_without_docker
with_confirmation(proc) def test_with_confirmation(proc, TIMEOUT):
history_changed(proc, u'echo test') with_confirmation(proc, TIMEOUT)
history_changed(proc, TIMEOUT, u'echo test')
@functional @pytest.mark.functional
def test_select_command_with_arrows(proc): @pytest.mark.once_without_docker
select_command_with_arrows(proc) def test_select_command_with_arrows(proc, TIMEOUT):
history_changed(proc, u'git push') select_command_with_arrows(proc, TIMEOUT)
history_changed(proc, TIMEOUT, u'git help')
@functional @pytest.mark.functional
def test_refuse_with_confirmation(proc): @pytest.mark.once_without_docker
refuse_with_confirmation(proc) def test_refuse_with_confirmation(proc, TIMEOUT):
history_not_changed(proc) refuse_with_confirmation(proc, TIMEOUT)
history_not_changed(proc, TIMEOUT)
@functional @pytest.mark.functional
def test_without_confirmation(proc): @pytest.mark.once_without_docker
without_confirmation(proc) def test_without_confirmation(proc, TIMEOUT):
history_changed(proc, u'echo test') without_confirmation(proc, TIMEOUT)
history_changed(proc, TIMEOUT, u'echo test')

View File

@ -1,65 +0,0 @@
import pytest
import os
import subprocess
import shutil
from tempfile import mkdtemp
from pathlib import Path
import sys
import pexpect
from tests.utils import root
bare = os.environ.get('BARE')
enabled = os.environ.get('FUNCTIONAL')
def build_container(tag, dockerfile, copy_src=False):
tmpdir = mkdtemp()
try:
if copy_src:
subprocess.call(['cp', '-a', str(root), tmpdir])
dockerfile_path = Path(tmpdir).joinpath('Dockerfile')
with dockerfile_path.open('w') as file:
file.write(dockerfile)
if subprocess.call(['docker', 'build', '--tag={}'.format(tag), tmpdir]) != 0:
raise Exception("Can't build a container")
finally:
shutil.rmtree(tmpdir)
def spawn(request, tag, dockerfile, cmd, install=True, copy_src=False):
if bare:
proc = pexpect.spawnu(cmd)
else:
tag = 'thefuck/{}'.format(tag)
build_container(tag, dockerfile, copy_src)
proc = pexpect.spawnu('docker run --rm=true --volume {}:/src --tty=true '
'--interactive=true {} {}'.format(root, tag, cmd))
if install:
proc.sendline('pip install /src')
proc.sendline('cd /')
proc.logfile = sys.stdout
def _finalizer():
proc.terminate()
if not bare:
container_id = subprocess.check_output(['docker', 'ps']) \
.decode('utf-8').split('\n')[-2].split()[0]
subprocess.check_call(['docker', 'kill', container_id])
request.addfinalizer(_finalizer)
return proc
def images(*items):
if bare:
return [items[0]]
else:
return items
functional = pytest.mark.skipif(
not enabled,
reason='Functional tests are disabled by default.')

View File

@ -103,6 +103,10 @@ def fix_command():
run_command(command, selected_command, settings) run_command(command, selected_command, settings)
def _get_current_version():
return pkg_resources.require('thefuck')[0].version
def print_alias(entry_point=True): def print_alias(entry_point=True):
if entry_point: if entry_point:
warn('`thefuck-alias` is deprecated, use `thefuck --alias` instead.') warn('`thefuck-alias` is deprecated, use `thefuck --alias` instead.')
@ -120,8 +124,7 @@ def main():
parser = ArgumentParser(prog='thefuck') parser = ArgumentParser(prog='thefuck')
parser.add_argument('-v', '--version', parser.add_argument('-v', '--version',
action='version', action='version',
version='%(prog)s {}'.format( version='%(prog)s {}'.format(_get_current_version()))
pkg_resources.require('thefuck')[0].version))
parser.add_argument('-a', '--alias', parser.add_argument('-a', '--alias',
action='store_true', action='store_true',
help='[custom-alias-name] prints alias for current shell') help='[custom-alias-name] prints alias for current shell')