From b1b7b93196ecc22fa1e97589ccb190a1f27e7a8b Mon Sep 17 00:00:00 2001 From: Meni Yakove <441263+myakove@users.noreply.github.com> Date: Thu, 7 Apr 2022 15:39:06 +0300 Subject: [PATCH] Use packaging.version (#125) * Use packaging.version, distutils.version is deprecated * Use packaging.version, distutils.version is deprecated --- pytest_jira.py | 6 +++--- requirements.txt | 1 + tests/requirements.txt | 1 + tests/test_jira.py | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pytest_jira.py b/pytest_jira.py index df1a241..37929e4 100644 --- a/pytest_jira.py +++ b/pytest_jira.py @@ -11,7 +11,7 @@ import os import re import sys -from distutils.version import LooseVersion +from packaging.version import Version from json import JSONDecodeError import pytest @@ -91,7 +91,7 @@ def is_issue_resolved(self, issue_id): return not self.is_affected(issue_id) def get_marker(self, item): - if LooseVersion(pytest.__version__) >= LooseVersion("3.6.0"): + if Version(pytest.__version__) >= Version("3.6.0"): return item.get_closest_marker("jira") else: return item.keywords.get("jira") @@ -276,7 +276,7 @@ def __init__(self, strategy, docs, pattern): def _get_marks(self, item): marks = [] - if LooseVersion(pytest.__version__) >= LooseVersion("3.6.0"): + if Version(pytest.__version__) >= Version("3.6.0"): for mark in item.iter_markers("jira"): marks.append(mark) else: diff --git a/requirements.txt b/requirements.txt index fd4f16d..c8d373e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ six requests>=2.13.0 retry>=0.9.2 marshmallow>=3.2.0 +packaging \ No newline at end of file diff --git a/tests/requirements.txt b/tests/requirements.txt index 25152de..2370031 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,2 +1,3 @@ flake8 coverage +packaging \ No newline at end of file diff --git a/tests/test_jira.py b/tests/test_jira.py index 68b7e9e..bdab418 100644 --- a/tests/test_jira.py +++ b/tests/test_jira.py @@ -1,5 +1,5 @@ import os -from distutils.version import LooseVersion +from packaging.version import Version import pytest @@ -916,7 +916,7 @@ def test_pass(): @pytest.mark.skipif( - LooseVersion(pytest.__version__) < LooseVersion("3.0.0"), + Version(pytest.__version__) < Version("3.0.0"), reason="requires pytest-3 or higher") def test_jira_marker_with_parametrize_pytest3(testdir): """""" @@ -936,7 +936,7 @@ def test_fail(arg): @pytest.mark.skipif( - LooseVersion(pytest.__version__) >= LooseVersion("3.0.0"), + Version(pytest.__version__) >= Version("3.0.0"), reason="requires pytest-2 or lower") def test_jira_marker_with_parametrize_pytest2(testdir): """"""