|
5 | 5 | import typing as t
|
6 | 6 | from django.test import TestCase
|
7 | 7 | import pytest
|
| 8 | +from django import VERSION |
| 9 | +from packaging.version import parse as parse_version |
8 | 10 |
|
9 | 11 |
|
10 | 12 | def get_postgresql_version() -> t.Tuple[int, ...]:
|
@@ -38,17 +40,17 @@ def test(self):
|
38 | 40 | expected_db_ver = os.environ.get("TEST_DATABASE_VERSION", None)
|
39 | 41 | expected_client = os.environ.get("TEST_DATABASE_CLIENT_VERSION", None)
|
40 | 42 |
|
41 |
| - expected_python = tuple(int(v) for v in expected_python.split(".") if v) |
42 |
| - assert sys.version_info[: len(expected_python)] == expected_python, ( |
43 |
| - f"Python Version Mismatch: {sys.version_info[: len(expected_python)]} != " |
44 |
| - f"{expected_python}" |
| 43 | + expected_python = parse_version(expected_python) |
| 44 | + assert sys.version_info[:2] == (expected_python.major, expected_python.minor), ( |
| 45 | + f"Python Version Mismatch: {sys.version_info[:2]} != {expected_python}" |
45 | 46 | )
|
46 | 47 |
|
47 | 48 | try:
|
48 |
| - expected_django = tuple(int(v) for v in expected_django.split(".") if v) |
49 |
| - assert django.VERSION[: len(expected_django)] == expected_django, ( |
50 |
| - f"Django Version Mismatch: {django.VERSION[: len(expected_django)]} != " |
51 |
| - f"{expected_django}" |
| 49 | + dj_actual = VERSION[:2] |
| 50 | + expected_django = parse_version(expected_django) |
| 51 | + dj_expected = (expected_django.major, expected_django.minor) |
| 52 | + assert dj_actual == dj_expected, ( |
| 53 | + f"Django Version Mismatch: {dj_actual} != {expected_django}" |
52 | 54 | )
|
53 | 55 | except ValueError:
|
54 | 56 | assert expected_django == django.__version__
|
|
0 commit comments