From b12660f1a8adf6b1e0b5560d9c145ef519d5975c Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sat, 23 Jan 2016 11:56:24 +0100 Subject: [PATCH] Warn when running under Python 2 See #219 --- tests/conftest.py | 5 +++++ tests/storage/dav/__init__.py | 6 +++++- vdirsyncer/cli/__init__.py | 10 ++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 44de373..f233759 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -14,6 +14,11 @@ def setup_logging(): click_log.basic_config('vdirsyncer').setLevel(logging.DEBUG) +@pytest.fixture(autouse=True) +def suppress_py2_warning(monkeypatch): + monkeypatch.setattr('vdirsyncer.cli._check_python2', lambda: None) + + try: import pytest_benchmark except ImportError: diff --git a/tests/storage/dav/__init__.py b/tests/storage/dav/__init__.py index 3c2a8f4..dd80b81 100644 --- a/tests/storage/dav/__init__.py +++ b/tests/storage/dav/__init__.py @@ -34,7 +34,11 @@ class DavStorageTests(ServerMixin, StorageTests): monkeypatch.setattr('requests.sessions.Session.request', breakdown) - assert list(s.get_multi([])) == [] + try: + assert list(s.get_multi([])) == [] + finally: + # Make sure monkeypatch doesn't interfere with DAV server teardown + monkeypatch.undo() def test_dav_unicode_href(self, s, get_item, monkeypatch): if self.dav_server != 'radicale': diff --git a/vdirsyncer/cli/__init__.py b/vdirsyncer/cli/__init__.py index eeb195d..2983c1e 100644 --- a/vdirsyncer/cli/__init__.py +++ b/vdirsyncer/cli/__init__.py @@ -8,6 +8,7 @@ import click import click_log from .. import __version__, log +from ..utils.compat import PY2 cli_logger = log.get(__name__) @@ -61,6 +62,14 @@ def validate_verbosity(ctx, param, value): return x +def _check_python2(): + if PY2: + cli_logger.warning('Python 2 support will be dropped. Please switch ' + 'to at least Python 3.3 as soon as possible. See ' + 'https://github.com/untitaker/vdirsyncer/issues/219' + ' for more information.') + + @click.group() @click_log.init('vdirsyncer') @click_log.simple_verbosity_option() @@ -71,6 +80,7 @@ def app(ctx): ''' vdirsyncer -- synchronize calendars and contacts ''' + _check_python2() from .config import load_config if not ctx.config: