diff --git a/tests/test_config.py b/tests/test_config.py index f38bcfc4..fa938795 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,10 +1,10 @@ import json +import sys from datetime import date from datetime import timedelta import pytest from dateutil.relativedelta import relativedelta -from flask import __version__ as flask_version from flask import Flask from flask_jwt_extended import JWTManager @@ -12,6 +12,20 @@ from flask_jwt_extended.internal_utils import JSONEncoder +def get_package_version(package_name): + if sys.version_info >= (3, 8): + # Use importlib.metadata for Python 3.8 and newer + import importlib.metadata + + return importlib.metadata.version(package_name) + else: + # Use pkg_resources for older versions + import pkg_resources + + return pkg_resources.get_distribution(package_name).version + + +flask_version = get_package_version("flask") flask_version_tuple = tuple(map(int, flask_version.split("."))) diff --git a/tox.ini b/tox.ini index 5a91819b..843b0c11 100644 --- a/tox.ini +++ b/tox.ini @@ -27,6 +27,7 @@ deps = python-dateutil types-python-dateutil mypy + types-setuptools [testenv:coverage] commands =