diff --git a/tests/test_init.py b/tests/test_init.py new file mode 100644 index 0000000..2a40a6e --- /dev/null +++ b/tests/test_init.py @@ -0,0 +1,12 @@ +import sys + +import pytest + +from thehive4py import _warn_old_py_version + + +def test_warn_old_py_version(): + actual_py_version = sys.version_info + dummy_min_py_version = (actual_py_version[0], actual_py_version[1] + 1) + with pytest.deprecated_call(): + _warn_old_py_version(min_py_version=dummy_min_py_version) diff --git a/thehive4py/__init__.py b/thehive4py/__init__.py index 21f8458..fec3ac5 100644 --- a/thehive4py/__init__.py +++ b/thehive4py/__init__.py @@ -1 +1,20 @@ from thehive4py.client import TheHiveApi + + +def _warn_old_py_version(min_py_version=(3, 9)): + import sys + import warnings + + if sys.version_info < min_py_version: + warnings.warn( + message=( + "thehive4py will drop support for Python versions below " + f"{min_py_version[0]}.{min_py_version[1]}, as they have reached their " + "end of life. Please upgrade to a newer version as soon as possible." + ), + category=DeprecationWarning, + stacklevel=3, + ) + + +_warn_old_py_version()