From 5ed8b8c728b3c637d6f981aee235483065514bf3 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Tue, 17 Jul 2018 06:29:45 +0700 Subject: [PATCH] bears/: Update required Python version to 3.4.4 coala updated its minimum version to 3.4.4 a while ago and bears was not also updated. Adds tests to cover assert_supported_version, so that the pragma no cover can be removed and setup.py does not need to be run by coverage. Related to https://github.com/coala/coala/issues/4350 --- .ci/check_unsupported.sh | 2 +- bears/__init__.py | 6 +++--- tests/coalaBearTest.py | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.ci/check_unsupported.sh b/.ci/check_unsupported.sh index 6d73b7f16f..95a6839ca8 100755 --- a/.ci/check_unsupported.sh +++ b/.ci/check_unsupported.sh @@ -34,6 +34,6 @@ fi # error when no lines selected by grep set -e -grep -q 'coala supports only python 3.4 or later' setup.log +grep -q 'coala supports only python 3.4.4 or later' setup.log echo "Unsupported check completed successfully" diff --git a/bears/__init__.py b/bears/__init__.py index 99b1057dc2..32667843dd 100644 --- a/bears/__init__.py +++ b/bears/__init__.py @@ -18,9 +18,9 @@ __version__ = VERSION -def assert_supported_version(): # pragma: no cover - if sys.version_info < (3, 4): - print('coala supports only python 3.4 or later.') +def assert_supported_version(): + if sys.version_info < (3, 4, 4): + print('coala supports only python 3.4.4 or later.') exit(4) diff --git a/tests/coalaBearTest.py b/tests/coalaBearTest.py index a9f810959d..41bc34b406 100644 --- a/tests/coalaBearTest.py +++ b/tests/coalaBearTest.py @@ -4,6 +4,8 @@ import bears import coalib +from bears import assert_supported_version + class coalaBearTest(unittest.TestCase): @@ -23,3 +25,20 @@ def test_check_coala_version(self): bears.check_coala_version() self.assertIn('Version mismatch between coala', cm.output[0]) + + @unittest.mock.patch('sys.version_info', tuple((2, 7, 11))) + def test_python_version_27(self): + with self.assertRaises(SystemExit) as cm: + assert_supported_version() + + self.assertEqual(cm.exception.code, 4) + + @unittest.mock.patch('sys.version_info', tuple((3, 3, 6))) + def test_python_version_33(self): + with self.assertRaises(SystemExit) as cm: + assert_supported_version() + + self.assertEqual(cm.exception.code, 4) + + def test_python_version_34(self): + assert_supported_version()