Skip to content
Snippets Groups Projects
Commit 96ca94a1 authored by Marc Troelitzsch's avatar Marc Troelitzsch Committed by Adam Williamson
Browse files

test: replace pkg_resources with importlib.metadata for Python 3.8+

This change replaces the deprecated `pkg_resources` (part of
`setuptools`) with `importlib.metadata` for Python 3.8 and above.

Switching to `importlib.metadata` allows us to drop the test-dependency
on `setuptools` and gets rid of the `DeprecationWarning` raised by
certain versions of `pkg_resources` when being imported:

```
DeprecationWarning: pkg_resources is deprecated as an API
```
parent f8ebc2c1
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,7 @@ testing = [ ...@@ -36,7 +36,7 @@ testing = [
"pytest-cov", "pytest-cov",
"responses>=0.3.0", "responses>=0.3.0",
"responses!=0.6.0", "responses!=0.6.0",
"setuptools", "setuptools; python_version < '3.8'",
] ]
[project.urls] [project.urls]
......
import json import json
import logging import logging
import sys
import time import time
import unittest import unittest
import unittest.mock as mock import unittest.mock as mock
from io import BytesIO from io import BytesIO
import pkg_resources # part of setuptools
import pytest import pytest
import requests import requests
import responses import responses
...@@ -125,7 +125,15 @@ class TestClient(TestCase): ...@@ -125,7 +125,15 @@ class TestClient(TestCase):
def testVersion(self): def testVersion(self):
# The version specified in setup.py should equal the one specified in client.py # The version specified in setup.py should equal the one specified in client.py
version = pkg_resources.require("mwclient")[0].version
if sys.version_info >= (3, 8):
import importlib.metadata
version = importlib.metadata.version("mwclient")
else:
import pkg_resources # part of setuptools
version = pkg_resources.require("mwclient")[0].version
assert version == mwclient.__version__ assert version == mwclient.__version__
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment