Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 291056c

Browse files
committed
fix environment verification to work with prereleases
1 parent bf9a81a commit 291056c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

‎tests/test_verify_environment.py‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import typing as t
66
from django.test import TestCase
77
import pytest
8+
from django import VERSION
9+
from packaging.version import parse as parse_version
810

911

1012
def get_postgresql_version() -> t.Tuple[int, ...]:
@@ -38,17 +40,17 @@ def test(self):
3840
expected_db_ver = os.environ.get("TEST_DATABASE_VERSION", None)
3941
expected_client = os.environ.get("TEST_DATABASE_CLIENT_VERSION", None)
4042

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}"
4546
)
4647

4748
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}"
5254
)
5355
except ValueError:
5456
assert expected_django == django.__version__

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /