2015-09-07 16:59:10 +01:00
|
|
|
from pathlib import Path
|
2015-07-10 15:58:41 +01:00
|
|
|
import pytest
|
2015-09-07 10:12:16 +01:00
|
|
|
from thefuck import conf
|
2015-07-10 15:58:41 +01:00
|
|
|
|
|
|
|
|
2015-09-05 23:13:44 +01: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 15:58:41 +01:00
|
|
|
@pytest.fixture
|
|
|
|
def no_memoize(monkeypatch):
|
|
|
|
monkeypatch.setattr('thefuck.utils.memoize.disabled', True)
|
2015-09-01 10:51:41 +01:00
|
|
|
|
|
|
|
|
2015-09-07 10:12:16 +01:00
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
def settings(request):
|
2015-09-07 16:59:10 +01:00
|
|
|
def _reset_settings():
|
|
|
|
conf.settings.clear()
|
|
|
|
conf.settings.update(conf.DEFAULT_SETTINGS)
|
|
|
|
|
|
|
|
request.addfinalizer(_reset_settings)
|
|
|
|
conf.settings.user_dir = Path('~/.thefuck')
|
2015-09-07 10:12:16 +01:00
|
|
|
return conf.settings
|
|
|
|
|
|
|
|
|
2015-09-01 10:51:41 +01:00
|
|
|
@pytest.fixture
|
2015-09-07 10:12:16 +01:00
|
|
|
def no_colors(settings):
|
|
|
|
settings.no_colors = True
|
2015-09-02 09:10:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
def no_cache(monkeypatch):
|
|
|
|
monkeypatch.setattr('thefuck.utils.cache.disabled', True)
|
2015-09-05 23:13:44 +01: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')
|