2015-09-07 18:59:10 +03:00
|
|
|
from pathlib import Path
|
2015-07-10 17:58:41 +03:00
|
|
|
import pytest
|
2016-01-29 13:09:40 +03:00
|
|
|
from thefuck import shells
|
2016-02-22 18:40:28 +03:00
|
|
|
from thefuck import conf, const
|
2015-07-10 17:58:41 +03:00
|
|
|
|
2016-01-29 13:09:40 +03:00
|
|
|
shells.shell = shells.Generic()
|
|
|
|
|
2015-07-10 17:58:41 +03:00
|
|
|
|
2015-09-06 01:13:44 +03:00
|
|
|
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")
|
|
|
|
|
|
|
|
|
2015-07-10 17:58:41 +03:00
|
|
|
@pytest.fixture
|
|
|
|
def no_memoize(monkeypatch):
|
|
|
|
monkeypatch.setattr('thefuck.utils.memoize.disabled', True)
|
2015-09-01 12:51:41 +03:00
|
|
|
|
|
|
|
|
2015-09-07 12:12:16 +03:00
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
def settings(request):
|
2015-09-07 18:59:10 +03:00
|
|
|
def _reset_settings():
|
|
|
|
conf.settings.clear()
|
2016-02-22 18:40:28 +03:00
|
|
|
conf.settings.update(const.DEFAULT_SETTINGS)
|
2015-09-07 18:59:10 +03:00
|
|
|
|
|
|
|
request.addfinalizer(_reset_settings)
|
|
|
|
conf.settings.user_dir = Path('~/.thefuck')
|
2015-09-07 12:12:16 +03:00
|
|
|
return conf.settings
|
|
|
|
|
|
|
|
|
2015-09-01 12:51:41 +03:00
|
|
|
@pytest.fixture
|
2015-09-07 12:12:16 +03:00
|
|
|
def no_colors(settings):
|
|
|
|
settings.no_colors = True
|
2015-09-02 11:10:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
def no_cache(monkeypatch):
|
|
|
|
monkeypatch.setattr('thefuck.utils.cache.disabled', True)
|
2015-09-06 01:13:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
@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')
|
2015-09-08 15:24:49 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def source_root():
|
|
|
|
return Path(__file__).parent.parent.resolve()
|
2016-01-29 13:09:40 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def set_shell(monkeypatch, request):
|
|
|
|
def _set(cls):
|
|
|
|
shell = cls()
|
|
|
|
monkeypatch.setattr('thefuck.shells.shell', shell)
|
|
|
|
request.addfinalizer()
|
|
|
|
return shell
|
|
|
|
|
|
|
|
return _set
|