Skip to content

Commit

Permalink
Avoid using distutils to check pytest version.
Browse files Browse the repository at this point in the history
Fixes the error seen in #172 without dropping the old pytest branches. There's no need for ``distutils.StrictVersion`` for simple version comparisons.
  • Loading branch information
adamchainz authored and jamielennox committed Feb 10, 2022
1 parent ad0bb1a commit 180e653
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions requests_mock/contrib/_pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
# can now just use @fixture, so we handle both of those cases as well.

try:
from distutils import version
_pytest_version = version.StrictVersion(pytest.__version__)
_pytest29 = _pytest_version >= version.StrictVersion('2.9.0')
_pytest30 = _pytest_version >= version.StrictVersion('3.0.0')
_pytest_version = tuple([
int(x) for x in pytest.__version__.split('.')[:2]
])
_pytest29 = _pytest_version >= (2, 9)
_pytest30 = _pytest_version >= (3, 0)
except Exception:
_pytest29 = False
_pytest30 = False
Expand Down

0 comments on commit 180e653

Please sign in to comment.