run-tests: fix a crash when using the coverage options
35bf7f23b84c attempted to transition away from `distutils`, but the `packaging`
code lacks `StrictVersion`. I have no idea when `packaging.version` became
available, but I have it in python 3.6, so that should be good enough. For some
reason, the import checker thinks this is a local import, and needs help to
decide otherwise.
Alternately we could ditch the version check entirely, because `coverage` is
currently at 7.2.1, and the original check was added back in 2010.
--- a/contrib/import-checker.py Tue Mar 07 13:39:31 2023 +0100
+++ b/contrib/import-checker.py Tue Mar 07 23:38:14 2023 -0500
@@ -232,6 +232,7 @@
yield 'importlib.abc' # python3 only
yield 'importlib.machinery' # python3 only
yield 'importlib.util' # python3 only
+ yield 'packaging.version'
for m in 'fcntl', 'grp', 'pwd', 'termios': # Unix only
yield m
for m in 'cPickle', 'datetime': # in Python (not C) on PyPy
--- a/tests/run-tests.py Tue Mar 07 13:39:31 2023 +0100
+++ b/tests/run-tests.py Tue Mar 07 23:38:14 2023 -0500
@@ -54,6 +54,7 @@
import json
import multiprocessing
import os
+import packaging.version as version
import platform
import queue
import random
@@ -72,12 +73,6 @@
import uuid
import xml.dom.minidom as minidom
-try:
- # PEP 632 recommend the use of `packaging.version` to replace the
- # deprecated `distutil.version`. So lets do it.
- import packaging.version as version
-except ImportError:
- import distutils.version as version
if sys.version_info < (3, 5, 0):
print(
@@ -799,8 +794,8 @@
try:
import coverage
- covver = version.StrictVersion(coverage.__version__).version
- if covver < (3, 3):
+ covver = version.Version(coverage.__version__)
+ if covver < version.Version("3.3"):
parser.error('coverage options require coverage 3.3 or later')
except ImportError:
parser.error('coverage options now require the coverage package')