Skip to content

Improve TestKit glue #810

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

Merged
merged 4 commits into from
Oct 3, 2022
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
25 changes: 15 additions & 10 deletions testkit/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions testkit/_common.py
Original file line number Diff line number Diff line change
@@ -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)
29 changes: 23 additions & 6 deletions testkit/backend.py
Original file line number Diff line number Diff line change
@@ -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"])
16 changes: 5 additions & 11 deletions testkit/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
20 changes: 20 additions & 0 deletions testkit/integration.py
Original file line number Diff line number Diff line change
@@ -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
29 changes: 20 additions & 9 deletions testkit/unittests.py
Original file line number Diff line number Diff line change
@@ -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"])
3 changes: 3 additions & 0 deletions tox-unit.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[tox]
envlist =
py36
py37
py38
py39

[testenv]
deps =
Expand Down