[3.4] Add test for presence of upper and lower bound on Python version (#5198) (#5282)

* Add test for presence of upper and lower bound on Python version

* [part 1/3] Test that this works, DO NOT MERGE

* [part 2/3] Test that this works, DO NOT MERGE

* [part 3/3] Revert unwanted changes, NOW YOU CAN MERGE!
(cherry picked from commit 6f0a8b11d7)

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
Red-GitHubBot
2021-09-08 22:09:55 +02:00
committed by GitHub
parent 96421a6dfa
commit 2f8f121bb0

View File

@@ -1,3 +1,6 @@
import importlib.metadata
import pkg_resources
from redbot import core
from redbot.core import VersionInfo
@@ -34,3 +37,17 @@ def test_version_info_lt():
def test_version_info_gt():
assert VersionInfo.from_str(version_tests[1]) > VersionInfo.from_str(version_tests[0])
def test_python_version_has_upper_and_lower_bound():
"""
Due to constant issues in support with Red being installed on a Python version that was not
supported by any Red version, it is important that we have both an upper and lower bound set.
"""
requires_python = importlib.metadata.metadata("Red-DiscordBot")["Requires-Python"]
assert requires_python is not None
# `pkg_resources` needs a regular requirement string, so "x" serves as requirement's name here
req = pkg_resources.Requirement.parse(f"x{requires_python}")
assert any(op in ("<", "<=") for op, version in req.specs)
assert any(op in (">", ">=") for op, version in req.specs)