From cdd5f21e88fe037627a5b01fd5999e7133877e59 Mon Sep 17 00:00:00 2001 From: nvbn Date: Sun, 6 Sep 2015 01:13:44 +0300 Subject: [PATCH] Add `functional` marker --- .travis.yml | 5 ++--- README.md | 2 +- tests/conftest.py | 14 ++++++++++++++ tests/functional/test_bash.py | 9 ++++----- tests/functional/test_fish.py | 9 ++++----- tests/functional/test_install.py | 4 +--- tests/functional/test_performance.py | 3 +-- tests/functional/test_tcsh.py | 9 ++++----- tests/functional/test_zsh.py | 9 ++++----- tests/functional/utils.py | 8 -------- 10 files changed, 35 insertions(+), 37 deletions(-) delete mode 100644 tests/functional/utils.py diff --git a/.travis.yml b/.travis.yml index c74827ff..f75836e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: python +sudo: false python: - "3.4" - "3.3" @@ -14,8 +15,6 @@ addons: - tcsh - pandoc - git -env: - - FUNCTIONAL=true install: - pip install coveralls - pip install -r requirements.txt @@ -23,5 +22,5 @@ install: - rm -rf build script: - export COVERAGE_PYTHON_VERSION=python-${TRAVIS_PYTHON_VERSION:0:1} - - coverage run --source=thefuck,tests -m py.test -v --capture=sys --run-without-docker + - coverage run --source=thefuck,tests -m py.test -v --capture=sys --run-without-docker --enable-functional after_success: coveralls diff --git a/README.md b/README.md index 75eccb3d..5181adec 100644 --- a/README.md +++ b/README.md @@ -326,7 +326,7 @@ py.test Run unit and functional tests (requires docker): ```bash -FUNCTIONAL=true py.test +py.test --enable-functional ``` For sending package to pypi: diff --git a/tests/conftest.py b/tests/conftest.py index f05cd222..9e115352 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,6 +2,13 @@ import pytest 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 def no_memoize(monkeypatch): monkeypatch.setattr('thefuck.utils.memoize.disabled', True) @@ -15,3 +22,10 @@ def settings(): @pytest.fixture(autouse=True) def no_cache(monkeypatch): 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') diff --git a/tests/functional/test_bash.py b/tests/functional/test_bash.py index 53d779b7..91859341 100644 --- a/tests/functional/test_bash.py +++ b/tests/functional/test_bash.py @@ -2,7 +2,6 @@ import pytest from tests.functional.plots import with_confirmation, without_confirmation, \ refuse_with_confirmation, history_changed, history_not_changed, \ select_command_with_arrows -from tests.functional.utils import functional containers = ((u'thefuck/ubuntu-python3-bash', u'''FROM ubuntu:latest @@ -30,25 +29,25 @@ def proc(request, spawnu, run_without_docker): return proc -@functional +@pytest.mark.functional def test_with_confirmation(proc, TIMEOUT): with_confirmation(proc, TIMEOUT) history_changed(proc, TIMEOUT, u'echo test') -@functional +@pytest.mark.functional def test_select_command_with_arrows(proc, TIMEOUT): select_command_with_arrows(proc, TIMEOUT) history_changed(proc, TIMEOUT, u'git push') -@functional +@pytest.mark.functional def test_refuse_with_confirmation(proc, TIMEOUT): refuse_with_confirmation(proc, TIMEOUT) history_not_changed(proc, TIMEOUT) -@functional +@pytest.mark.functional def test_without_confirmation(proc, TIMEOUT): without_confirmation(proc, TIMEOUT) history_changed(proc, TIMEOUT, u'echo test') diff --git a/tests/functional/test_fish.py b/tests/functional/test_fish.py index 636fb3c5..eb02f053 100644 --- a/tests/functional/test_fish.py +++ b/tests/functional/test_fish.py @@ -1,7 +1,6 @@ import pytest from tests.functional.plots import with_confirmation, without_confirmation, \ refuse_with_confirmation, select_command_with_arrows -from tests.functional.utils import functional containers = (('thefuck/ubuntu-python3-fish', u'''FROM ubuntu:latest @@ -29,25 +28,25 @@ def proc(request, spawnu): return proc -@functional +@pytest.mark.functional @pytest.mark.skip_without_docker def test_with_confirmation(proc, TIMEOUT): with_confirmation(proc, TIMEOUT) -@functional +@pytest.mark.functional @pytest.mark.skip_without_docker def test_select_command_with_arrows(proc, TIMEOUT): select_command_with_arrows(proc, TIMEOUT) -@functional +@pytest.mark.functional @pytest.mark.skip_without_docker def test_refuse_with_confirmation(proc, TIMEOUT): refuse_with_confirmation(proc, TIMEOUT) -@functional +@pytest.mark.functional @pytest.mark.skip_without_docker def test_without_confirmation(proc, TIMEOUT): without_confirmation(proc, TIMEOUT) diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index 2fece023..4b2becb7 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -1,7 +1,5 @@ import pytest from thefuck.main import _get_current_version -from tests.functional.utils import functional - envs = ((u'bash', 'thefuck/ubuntu-bash', u''' FROM ubuntu:latest @@ -13,7 +11,7 @@ RUN dnf install -yy python-devel sudo wget gcc ''')) -@functional +@pytest.mark.functional @pytest.mark.skip_without_docker @pytest.mark.parametrize('shell, tag, dockerfile', envs) def test_installation(spawnu, shell, TIMEOUT, tag, dockerfile): diff --git a/tests/functional/test_performance.py b/tests/functional/test_performance.py index 1582a875..c9b69357 100644 --- a/tests/functional/test_performance.py +++ b/tests/functional/test_performance.py @@ -1,6 +1,5 @@ import pytest import time -from tests.functional.utils import functional dockerfile = u''' FROM ubuntu:latest @@ -40,7 +39,7 @@ def plot(proc, TIMEOUT): assert proc.expect([TIMEOUT, u'test']) -@functional +@pytest.mark.functional @pytest.mark.skip_without_docker @pytest.mark.benchmark(min_rounds=10) def test_performance(spawnu, TIMEOUT, benchmark): diff --git a/tests/functional/test_tcsh.py b/tests/functional/test_tcsh.py index 0614cdb1..c4c27e05 100644 --- a/tests/functional/test_tcsh.py +++ b/tests/functional/test_tcsh.py @@ -1,5 +1,4 @@ import pytest -from tests.functional.utils import functional from tests.functional.plots import with_confirmation, without_confirmation, \ refuse_with_confirmation, select_command_with_arrows @@ -30,22 +29,22 @@ def proc(request, spawnu, run_without_docker): return proc -@functional +@pytest.mark.functional def test_with_confirmation(proc, TIMEOUT): with_confirmation(proc, TIMEOUT) -@functional +@pytest.mark.functional def test_select_command_with_arrows(proc, TIMEOUT): select_command_with_arrows(proc, TIMEOUT) -@functional +@pytest.mark.functional def test_refuse_with_confirmation(proc, TIMEOUT): refuse_with_confirmation(proc, TIMEOUT) -@functional +@pytest.mark.functional def test_without_confirmation(proc, TIMEOUT): without_confirmation(proc, TIMEOUT) diff --git a/tests/functional/test_zsh.py b/tests/functional/test_zsh.py index 498d22ed..8d8bbc34 100644 --- a/tests/functional/test_zsh.py +++ b/tests/functional/test_zsh.py @@ -1,5 +1,4 @@ import pytest -from tests.functional.utils import functional from tests.functional.plots import with_confirmation, without_confirmation, \ refuse_with_confirmation, history_changed, history_not_changed, select_command_with_arrows @@ -34,25 +33,25 @@ def proc(request, spawnu, run_without_docker): return proc -@functional +@pytest.mark.functional def test_with_confirmation(proc, TIMEOUT): with_confirmation(proc, TIMEOUT) history_changed(proc, TIMEOUT, u'echo test') -@functional +@pytest.mark.functional def test_select_command_with_arrows(proc, TIMEOUT): select_command_with_arrows(proc, TIMEOUT) history_changed(proc, TIMEOUT, u'git push') -@functional +@pytest.mark.functional def test_refuse_with_confirmation(proc, TIMEOUT): refuse_with_confirmation(proc, TIMEOUT) history_not_changed(proc, TIMEOUT) -@functional +@pytest.mark.functional def test_without_confirmation(proc, TIMEOUT): without_confirmation(proc, TIMEOUT) history_changed(proc, TIMEOUT, u'echo test') diff --git a/tests/functional/utils.py b/tests/functional/utils.py deleted file mode 100644 index 18dcb9df..00000000 --- a/tests/functional/utils.py +++ /dev/null @@ -1,8 +0,0 @@ -import pytest -import os - -enabled = os.environ.get('FUNCTIONAL') - -functional = pytest.mark.skipif( - not enabled, - reason='Functional tests are disabled by default.')