Source: python-pytest-freezegun
Version: 0.4.2-2
Severity: normal

Hello Thomas,

you did add a patch to python-pytest-freezegun to use distutils.version
in pytest_freezegun.py.

This provokes now while working on the package python-inline-snapshot
and fixing an issue in the -doc there a deprecation warning (also in the
test suite run) that is than also captured into one of the generated HTML files.

../../../usr/lib/python3/dist-packages/pytest_freezegun.py:20: 688 warnings
  /usr/lib/python3/dist-packages/pytest_freezegun.py:20: DeprecationWarning: 
distutils Version classes are deprecated. Use packaging.version instead.
    if LooseVersion(pytest.__version__) < LooseVersion('3.6.0'):


....
<a id="__codelineno-0-9" name="__codelineno-0-9" href="#__codelineno-0-9"></a>
<a id="__codelineno-0-10" name="__codelineno-0-10" 
href="#__codelineno-0-10"></a>ESC[33m=============================== warnings 
summary ===============================ESC[0m
<a id="__codelineno-0-11" name="__codelineno-0-11" 
href="#__codelineno-0-11"></a>../../usr/lib/python3/dist-packages/pytest_freezegun.py:20
<a id="__codelineno-0-12" name="__codelineno-0-12" 
href="#__codelineno-0-12"></a>../../usr/lib/python3/dist-packages/pytest_freezegun.py:20
<a id="__codelineno-0-13" name="__codelineno-0-13" 
href="#__codelineno-0-13"></a>  
/usr/lib/python3/dist-packages/pytest_freezegun.py:20: DeprecationWarning: 
distutils Version classes are deprecated. Use packaging.version instead.
<a id="__codelineno-0-14" name="__codelineno-0-14" 
href="#__codelineno-0-14"></a>    if LooseVersion(pytest.__version__) &lt; 
LooseVersion(&#39;3.6.0&#39;):
<a id="__codelineno-0-15" name="__codelineno-0-15" 
href="#__codelineno-0-15"></a>
<a id="__codelineno-0-16" name="__codelineno-0-16" 
href="#__codelineno-0-16"></a>-- Docs: 
https://docs.pytest.org/en/stable/how-to/capture-warnings.html
<a id="__codelineno-0-17" name="__codelineno-0-17" 
href="#__codelineno-0-17"></a>=============================== inline snapshot 
================================
....


This deprecation warning will go away if the usage of distutils here is
beeing dropped. I played around with basically this (as suggested by the
output from the warning):


$ git diff
diff --git a/debian/control b/debian/control
index 58c139e..b9225e0 100644
--- a/debian/control
+++ b/debian/control
@@ -13,7 +13,6 @@ Build-Depends:
  python3-setuptools,
 Build-Depends-Indep:
  python3-freezegun,
- python3-looseversion,
+ python3-packaging,
  python3-pytest,
 Standards-Version: 4.6.1
 Vcs-Browser: 
https://salsa.debian.org/homeassistant-team/deps/python-pytest-freezegun
@@ -24,7 +23,6 @@ Package: python3-pytest-freezegun
 Architecture: all
 Depends:
  python3-freezegun,
- python3-looseversion,
+ python3-packaging,
  python3-pytest,
  ${misc:Depends},
  ${python3:Depends},
diff --git a/pytest_freezegun.py b/pytest_freezegun.py
index a08133f..e4d2719 100644
--- a/pytest_freezegun.py
+++ b/pytest_freezegun.py
@@ -2,7 +2,7 @@
 
 import pytest
 
-from distutils.version import LooseVersion
+from packaging.version import Version
 from freezegun import freeze_time
 
 
@@ -14,7 +14,7 @@ def get_closest_marker(node, name):
     """
     Get our marker, regardless of pytest version
     """
-    if LooseVersion(pytest.__version__) < LooseVersion('3.6.0'):
+    if Version(pytest.__version__) < Version('3.6.0'):
         return node.get_marker('freeze_time')
     else:
         return node.get_closest_marker('freeze_time')

Would you mind to remove the existing patch and replace the version
checking by using packaging.version?


Thanks for consideration!

Regards
Carsten

-- System Information:
Debian Release: trixie/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 6.11.5-amd64 (SMP w/12 CPU threads; PREEMPT)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Reply via email to