Skip to content

Commit

Permalink
Avoid use of deprecated pkg_resources (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Dec 7, 2023
1 parent f967ece commit 35d8e65
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 9 deletions.
1 change: 0 additions & 1 deletion .config/requirements-lock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ pycparser==2.21
pytest==7.4.2
pyyaml==6.0.1
resolvelib==1.0.1
setuptools==68.2.2
tomli==2.0.1
2 changes: 1 addition & 1 deletion .config/requirements.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ansible-core>=2.14
pytest>=6,<8.0.0
setuptools
packaging
1 change: 0 additions & 1 deletion .config/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ requests==2.31.0
resolvelib==1.0.1
rich==13.6.0
rpds-py==0.10.6
setuptools==68.2.2
six==1.16.0
soupsieve==2.5
subprocess-tee==0.4.1
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ repos:
additional_dependencies:
- pytest
- ansible-core
- types-pkg_resources
- packaging
- repo: https://github.com/jazzband/pip-tools
rev: 7.3.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_ansible/has_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Fixme."""
import ansible

from pkg_resources import parse_version
from packaging.version import parse as parse_version


has_ansible_v2 = parse_version(ansible.__version__) >= parse_version("2.0.0")
Expand Down
6 changes: 3 additions & 3 deletions src/pytest_ansible/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import sys
import warnings

from importlib.metadata import version
from pathlib import Path

import pkg_resources
import pytest
import yaml

Expand Down Expand Up @@ -46,9 +46,9 @@ def molecule_pytest_configure(config):
# Add extra information that may be key for debugging failures
if hasattr(config, "_metadata"):
for package in ["molecule"]:
config._metadata["Packages"][package] = pkg_resources.get_distribution(
config._metadata["Packages"][package] = version(
package,
).version
)

if "Tools" not in config._metadata:
config._metadata["Tools"] = {}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_adhoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_become(testdir, option):
import ansible
import re
import os
from pkg_resources import parse_version
from packaging.version import parse as parse_version
@pytest.mark.ansible(inventory='{option.inventory}', host_pattern='localhost')
def test_func(ansible_module):
Expand Down

0 comments on commit 35d8e65

Please sign in to comment.