Compare major.minor python version to be expected one

This commit is contained in:
Ayaz Salikhov
2022-05-31 22:40:39 +04:00
parent 5e1a27a812
commit 84d041b9df
3 changed files with 9 additions and 15 deletions

View File

@@ -2,25 +2,23 @@
# Distributed under the terms of the Modified BSD License.
import logging
from packaging import version # type: ignore
from tests.conftest import TrackedContainer
LOGGER = logging.getLogger(__name__)
EXPECTED_PYTHON_VERSION = "3.10"
def test_python_version(
container: TrackedContainer, python_next_version: str = "3.11"
) -> None:
"""Check that python version is lower than the next version"""
LOGGER.info(f"Checking that python version is lower than {python_next_version}")
def test_python_version(container: TrackedContainer) -> None:
LOGGER.info(
f"Checking that python major.minor version is {EXPECTED_PYTHON_VERSION}"
)
logs = container.run_and_wait(
timeout=5,
tty=True,
command=["python", "--version"],
)
assert logs.startswith("Python ")
actual_python_version = version.parse(logs.split()[1])
assert actual_python_version < version.parse(
python_next_version
), f"Python version shall be lower than {python_next_version}"
full_version = logs.split()[1]
major_minor_version = full_version[: full_version.rfind(".")]
assert major_minor_version == EXPECTED_PYTHON_VERSION