NTSQLITE_BUILDPATH = os.path.join(PROJECT_ROOT, "ntsqlite", "sql", NT_DB_NAME)
NTSQLITE_DESTINATION = os.path.join(NUTRA_HOME, NT_DB_NAME)
-# Check Python version
+
+def version_check() -> None:
+ """Check Python version"""
+ # pylint: disable=global-statement
+ global PY_SYS_VER, PY_SYS_STR
+ PY_SYS_VER = sys.version_info[0:3]
+ PY_SYS_STR = ".".join(str(x) for x in PY_SYS_VER)
+
+ if PY_SYS_VER < PY_MIN_VER:
+ # TODO: make this testable with: `class CliConfig`?
+ raise RuntimeError(
+ "ERROR: %s requires Python %s or later to run" % (__title__, PY_MIN_STR),
+ "HINT: You're running Python %s" % PY_SYS_STR,
+ )
+
+
PY_MIN_VER = (3, 4, 3)
PY_SYS_VER = sys.version_info[0:3]
PY_MIN_STR = ".".join(str(x) for x in PY_MIN_VER)
PY_SYS_STR = ".".join(str(x) for x in PY_SYS_VER)
-if PY_SYS_VER < PY_MIN_VER:
- # TODO: make this testable with: `class CliConfig`?
- raise RuntimeError(
- "ERROR: %s requires Python %s or later to run" % (__title__, PY_MIN_STR),
- "HINT: You're running Python %s" % PY_SYS_STR,
- )
+# Run the check
+version_check()
# Console size, don't print more than it
BUFFER_WD = shutil.get_terminal_size()[0]
-#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 12 17:30:01 2024
import pytest
+from ntclient import version_check
+
@patch("sys.version_info", (3, 4, 0))
def test_archaic_python_version_raises_runtime_error() -> None:
"""Test that the correct error is raised when the Python version is too low."""
with pytest.raises(RuntimeError) as exc_info:
- # pylint: disable=import-outside-toplevel
- from ntclient import PY_MIN_VER, PY_SYS_VER, __title__
-
- assert __title__ == "nutra"
- assert PY_MIN_VER == (3, 4, 3)
- assert PY_SYS_VER == (3, 4, 0)
+ version_check()
assert "ERROR: nutra requires Python 3.4.3 or later to run" in str(exc_info.value)
assert "HINT: You're running Python 3.4.0" in str(exc_info.value)