mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
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.
30 lines
745 B
Python
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)
|