diff --git a/bin/test_python_floor.py b/bin/test_python_floor.py index d855cec3..1c5e0ef4 100644 --- a/bin/test_python_floor.py +++ b/bin/test_python_floor.py @@ -1,23 +1,23 @@ -import os import pathlib import re import shutil import subprocess +import sys import unittest ROOT = pathlib.Path(__file__).resolve().parents[1] -FLOOR = re.compile(r"Python (3\.\d+) or newer") -ON_FLOOR = "PYTHON_FLOOR_RUN" +FLOOR = re.compile(r"Python 3\.(\d+) or newer") class PythonFloor(unittest.TestCase): def test_the_suite_passes_on_the_python_the_readme_names_as_floor(self): - if os.environ.get(ON_FLOOR): - self.skipTest("already running on the floor interpreter") named = FLOOR.search((ROOT / "README.md").read_text(encoding="utf-8")) self.assertIsNotNone(named, "README.md's Install names `Python 3.N or newer`") - suite = ["python", "-m", "unittest", "discover", "-s", "bin", "-p", "test_*.py"] + floor = (3, int(named.group(1))) + if sys.version_info[:2] == floor: + self.skipTest("this run is on the floor") if shutil.which("uv") is None: self.fail("uv on PATH fetches the floor interpreter; see README.md's Test line") - ran = subprocess.run(["uv", "run", "--no-project", "--python", named.group(1), *suite], capture_output=True, cwd=ROOT, env={**os.environ, ON_FLOOR: "1"}, text=True) + suite = ["python", "-m", "unittest", "discover", "-s", "bin", "-p", "test_*.py"] + ran = subprocess.run(["uv", "run", "--no-project", "--python", "%d.%d" % floor, *suite], capture_output=True, cwd=ROOT, text=True) self.assertEqual(ran.returncode, 0, ran.stderr)