diff --git a/testkit/Dockerfile b/testkit/Dockerfile index 41e5ed28b..4685d473c 100644 --- a/testkit/Dockerfile +++ b/testkit/Dockerfile @@ -39,14 +39,19 @@ RUN git clone https://github.com/pyenv/pyenv.git .pyenv ENV PYENV_ROOT /.pyenv ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH -# Set minimum supported Python version -RUN pyenv install 3.6.13 -RUN pyenv rehash -RUN pyenv global 3.6.13 - -# Install Latest pip for each environment -# https://pip.pypa.io/en/stable/news/ -RUN python -m pip install --upgrade pip +# Setup python version +ENV PYTHON_VERSIONS 3.6 3.7 3.8 3.9 -# Install Python Testing Tools -RUN python -m pip install coverage tox +RUN for version in $PYTHON_VERSIONS; do \ + pyenv install $version:latest; \ + done +RUN pyenv rehash +RUN pyenv global $(pyenv versions --bare --skip-aliases) + +# Install Latest pip and setuptools for each environment +# + tox and tools for starting the tests +RUN for version in $PYTHON_VERSIONS; do \ + python$version -m pip install -U pip && \ + python$version -m pip install -U setuptools && \ + python$version -m pip install -U coverage tox; \ + done diff --git a/testkit/_common.py b/testkit/_common.py new file mode 100644 index 000000000..ff285ad5d --- /dev/null +++ b/testkit/_common.py @@ -0,0 +1,17 @@ +import os +import subprocess +import sys + + +TEST_BACKEND_VERSION = os.getenv("TEST_BACKEND_VERSION", "python") + + +def run(args, env=None): + return subprocess.run( + args, universal_newlines=True, stdout=sys.stdout, stderr=sys.stderr, + check=True, env=env + ) + + +def run_python(args, env=None): + run([TEST_BACKEND_VERSION, "-W", "error", *args], env=env) diff --git a/testkit/backend.py b/testkit/backend.py index 8fd811e22..088ff7951 100644 --- a/testkit/backend.py +++ b/testkit/backend.py @@ -1,8 +1,25 @@ -import subprocess -import sys +#!/usr/bin/env python + +# Copyright (c) "Neo4j" +# Neo4j Sweden AB [https://neo4j.com] +# +# This file is part of Neo4j. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +from _common import run_python + if __name__ == "__main__": - subprocess.check_call( - ["python", "-W", "error", "-m", "testkitbackend"], - stdout=sys.stdout, stderr=sys.stderr - ) + run_python(["-m", "testkitbackend"]) diff --git a/testkit/build.py b/testkit/build.py index 2a2b1eeff..dd1f318bc 100644 --- a/testkit/build.py +++ b/testkit/build.py @@ -4,17 +4,11 @@ """ -import subprocess -import sys - - -def run(args, env=None): - subprocess.run(args, universal_newlines=True, stdout=sys.stdout, - stderr=sys.stderr, check=True, env=env) +from _common import run_python if __name__ == "__main__": - run(["python", "setup.py", "build"]) - run(["python", "-m", "pip", "install", "-U", "pip"]) - run(["python", "-m", "pip", "install", "-Ur", - "testkitbackend/requirements.txt"]) + run_python(["setup.py", "build"]) + run_python(["-m", "pip", "install", "-U", "pip"]) + run_python(["-m", "pip", "install", "-Ur", + "testkitbackend/requirements.txt"]) diff --git a/testkit/integration.py b/testkit/integration.py index 244a421fe..590a9f449 100644 --- a/testkit/integration.py +++ b/testkit/integration.py @@ -1,2 +1,22 @@ +#!/usr/bin/env python + +# Copyright (c) "Neo4j" +# Neo4j Sweden AB [https://neo4j.com] +# +# This file is part of Neo4j. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + if __name__ == "__main__": pass diff --git a/testkit/unittests.py b/testkit/unittests.py index 997ade533..2210d58a3 100644 --- a/testkit/unittests.py +++ b/testkit/unittests.py @@ -1,14 +1,25 @@ -import subprocess -import sys +#!/usr/bin/env python +# Copyright (c) "Neo4j" +# Neo4j Sweden AB [https://neo4j.com] +# +# This file is part of Neo4j. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. -def run(args): - subprocess.run( - args, universal_newlines=True, stdout=sys.stdout, stderr=sys.stderr, - check=True - ) + +from _common import run_python if __name__ == "__main__": - run([ - "python", "-m", "tox", "-c", "tox-unit.ini"]) + run_python(["-m", "tox", "-c", "tox-unit.ini"]) diff --git a/tox-unit.ini b/tox-unit.ini index ea9bdc839..8d771723f 100644 --- a/tox-unit.ini +++ b/tox-unit.ini @@ -1,6 +1,9 @@ [tox] envlist = py36 + py37 + py38 + py39 [testenv] deps =