Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python minimum version 3.4.4 #2612

Merged
merged 4 commits into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .ci/check_moban.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ set -ex

: "${MOBAN_BRANCH:=master}"

git clone https://gitlab.com/coala/mobans \
if [ ! -d ../coala-mobans ]; then
git clone https://gitlab.com/coala/mobans \
--branch=${MOBAN_BRANCH} ../coala-mobans
fi

date

moban
git diff --exit-code
26 changes: 16 additions & 10 deletions .ci/check_unsupported.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,38 @@ set -o pipefail

set -x

# mypy and guess-language-spirit do not install on unsupported versions
sed -i.bak -E '/^(mypy|guess-language-spirit)/d' bear-requirements.txt
# Many bear dependencies do not install on unsupported versions
echo "" > bear-requirements.txt

# pylint installs pytest-runner, and 2.12 creates a version mismatch
# https://github.com/pytest-dev/pytest-runner/issues/40
# pbr failing on py33
pip install 'pytest-runner==2.12' 'pbr~=4.0.0'

python setup.py install | tee setup.log
python setup.py install 2>&1 | tee setup.log

retval=$?

set +x

# coalib.__init__.py should exit with 4 on unsupported versions of Python
# And setup.py emits something else.
if [[ $retval == 0 ]]; then
echo "Unexpected error code 0"
exit 1
else
echo "setup.py error code $retval ok"
# But bears setup.py sees retval 1.
if [[ $retval != 1 ]]; then
echo "Unexpected error code $retval"

# When the exit code is 0, use a non-zero exit code instead
if [[ $retval == 0 ]]; then
exit 127
fi
exit $retval
fi

# error when no lines selected by grep
set -e

grep -q 'coala supports only python 3.4 or later' setup.log
# The following is emitted on stdout
grep -q 'coala supports only python 3.4.4 or later' setup.log
# The following is emitted on stderr
grep -q 'error: Setup script exited with 4' setup.log

echo "Unsupported check completed successfully"
2 changes: 2 additions & 0 deletions .moban.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ targets:
- bear-requirements.txt: bear-requirements.txt.jj2
- .ci/appveyor.yml: ci/appveyor.yml.jj2
- .ci/run_with_env.cmd: run_with_env.cmd
- .ci/check_unsupported.sh: ci/check_unsupported.sh.jj2
- .ci/check_moban.sh: ci/check_moban.sh
- runtime.txt: runtime.txt
- netlify.toml: docs/netlify.toml
- coala-bears.cabal: coala-bears.cabal.jj2
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
6 changes: 1 addition & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ python_paths = .ci/
branch = True
cover_pylib = False
source =
.
omit =
tests/*
.ci/*
setup.py
bears

[coverage:report]
show_missing = True
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()