From 4b243e84012ae2b9391aad14ccda4a502942c313 Mon Sep 17 00:00:00 2001 From: romainx Date: Wed, 5 May 2021 21:19:13 +0200 Subject: [PATCH] Test Python version --- base-notebook/test/test_python.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 base-notebook/test/test_python.py diff --git a/base-notebook/test/test_python.py b/base-notebook/test/test_python.py new file mode 100644 index 00000000..6cbde99f --- /dev/null +++ b/base-notebook/test/test_python.py @@ -0,0 +1,19 @@ +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. +import logging + +from packaging import version + +LOGGER = logging.getLogger(__name__) + + +def test_python_version(container, python_max_version="3.9"): + """Check that python version is not higher than a max version""" + LOGGER.info(f"Checking that python version is lower than {python_max_version}") + c = container.run(tty=True, command=["start.sh"]) + cmd = c.exec_run("python --version") + output = cmd.output.decode("utf-8") + actual_python_version = version.parse(output.split()[1]) + assert actual_python_version < version.parse( + python_max_version + ), f"Python version shall be lower than {python_max_version}"