vdirsyncer/tests/system/cli/conftest.py
Hugo Osvaldo Barrera b1b4dd92fe Sort imports
I don't want to ever have to sort imports again. It's a poor use of
developer time. Automate this with a pre-commit hook, and check this on
CI.

Developers: I suggest you configure your editor to use
`reorder_python_imports`. It uses the standard sorting, and detects
first/third party libs well.
2020-06-09 14:34:45 +02:00

30 lines
745 B
Python

from textwrap import dedent
import pytest
from click.testing import CliRunner
import vdirsyncer.cli as cli
class _CustomRunner:
def __init__(self, tmpdir):
self.tmpdir = tmpdir
self.cfg = tmpdir.join('config')
self.runner = CliRunner()
def invoke(self, args, env=None, **kwargs):
env = env or {}
env.setdefault('VDIRSYNCER_CONFIG', str(self.cfg))
return self.runner.invoke(cli.app, args, env=env, **kwargs)
def write_with_general(self, data):
self.cfg.write(dedent('''
[general]
status_path = "{}/status/"
''').format(str(self.tmpdir)))
self.cfg.write(data, mode='a')
@pytest.fixture
def runner(tmpdir):
return _CustomRunner(tmpdir)