mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-19 04:21:14 +00:00
ebf1ea88f5
The pathlib backport module is no longer maintained. The development has moved to the pathlib2 module instead. Quoting from the pathlib's README: "Attention: this backport module isn't maintained anymore. If you want to report issues or contribute patches, please consider the pathlib2 project instead."
66 lines
1.5 KiB
Python
66 lines
1.5 KiB
Python
try:
|
|
from pathlib import Path
|
|
except ImportError:
|
|
from pathlib2 import Path
|
|
import pytest
|
|
from thefuck import shells
|
|
from thefuck import conf, const
|
|
|
|
shells.shell = shells.Generic()
|
|
|
|
|
|
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)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def settings(request):
|
|
def _reset_settings():
|
|
conf.settings.clear()
|
|
conf.settings.update(const.DEFAULT_SETTINGS)
|
|
|
|
request.addfinalizer(_reset_settings)
|
|
conf.settings.user_dir = Path('~/.thefuck')
|
|
return conf.settings
|
|
|
|
|
|
@pytest.fixture
|
|
def no_colors(settings):
|
|
settings.no_colors = True
|
|
|
|
|
|
@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')
|
|
|
|
|
|
@pytest.fixture
|
|
def source_root():
|
|
return Path(__file__).parent.parent.resolve()
|
|
|
|
|
|
@pytest.fixture
|
|
def set_shell(monkeypatch, request):
|
|
def _set(cls):
|
|
shell = cls()
|
|
monkeypatch.setattr('thefuck.shells.shell', shell)
|
|
request.addfinalizer()
|
|
return shell
|
|
|
|
return _set
|