Skip to content

Commit

Permalink
bears/: Update required Python version to 3.4.4
Browse files Browse the repository at this point in the history
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 coala/coala#4350
  • Loading branch information
jayvdb committed Jul 17, 2018
1 parent cf93dd5 commit 807b537
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .ci/check_unsupported.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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"
6 changes: 3 additions & 3 deletions bears/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
19 changes: 19 additions & 0 deletions tests/coalaBearTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import bears
import coalib

from bears import assert_supported_version


class coalaBearTest(unittest.TestCase):

Expand All @@ -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()

0 comments on commit 807b537

Please sign in to comment.