Skip to content

Commit

Permalink
Drop deprecated module PipPackage
Browse files Browse the repository at this point in the history
Fix #712 along the way
  • Loading branch information
philpep committed Aug 24, 2023
1 parent 0ec65bb commit c2af851
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 46 deletions.
10 changes: 0 additions & 10 deletions doc/source/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ host

:class:`testinfra.modules.pip.Pip` class

.. attribute:: pip_package

:class:`testinfra.modules.pip.PipPackage` class

.. attribute:: podman

:class:`testinfra.modules.podman.Podman` class
Expand Down Expand Up @@ -204,12 +200,6 @@ Pip
:members:


PipPackage
~~~~~~~~~~

.. autoclass:: testinfra.modules.pip.PipPackage


Podman
~~~~~~

Expand Down
1 change: 0 additions & 1 deletion testinfra/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"mount_point": "mountpoint:MountPoint",
"package": "package:Package",
"pip": "pip:Pip",
"pip_package": "pip:PipPackage",
"process": "process:Process",
"puppet_resource": "puppet:PuppetResource",
"facter": "puppet:Facter",
Expand Down
38 changes: 3 additions & 35 deletions testinfra/modules/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import json
import re
import warnings

from testinfra.modules.base import Module

Expand Down Expand Up @@ -58,7 +57,7 @@ def version(self):
def check(cls, pip_path="pip"):
"""Verify installed packages have compatible dependencies.
>>> cmd = host.pip_package.check()
>>> cmd = host.pip.check()
>>> cmd.rc
0
>>> cmd.stdout
Expand All @@ -76,7 +75,7 @@ def check(cls, pip_path="pip"):
def get_packages(cls, pip_path="pip"):
"""Get all installed packages and versions returned by `pip list`:
>>> host.pip_package.get_packages(pip_path='~/venv/website/bin/pip')
>>> host.pip.get_packages(pip_path='~/venv/website/bin/pip')
{'Django': {'version': '1.10.2'},
'mywebsite': {'version': '1.0a3', 'path': '/srv/website'},
'psycopg2': {'version': '2.6.2'}}
Expand Down Expand Up @@ -106,7 +105,7 @@ def get_packages(cls, pip_path="pip"):
def get_outdated_packages(cls, pip_path="pip"):
"""Get all outdated packages with current and latest version
>>> host.pip_package.get_outdated_packages(
>>> host.pip.get_outdated_packages(
... pip_path='~/venv/website/bin/pip')
{'Django': {'current': '1.10.2', 'latest': '1.10.3'}}
"""
Expand Down Expand Up @@ -134,34 +133,3 @@ def get_outdated_packages(cls, pip_path="pip"):
name, current, latest = _re_match(line, output_re)
pkgs[name] = {"current": current, "latest": latest}
return pkgs


class PipPackage(Pip):
""".. deprecated:: 6.2
Use :class:`~testinfra.modules.pip.Pip` instead.
"""

@staticmethod
def _deprecated():
"""Raise a `DeprecationWarning`"""
warnings.warn(
"Calling host.pip_package is deprecated, call host.pip instead",
category=DeprecationWarning,
stacklevel=2,
)

@classmethod
def check(cls, pip_path="pip"):
PipPackage._deprecated()
return super().check(pip_path=pip_path)

@classmethod
def get_packages(cls, pip_path="pip"):
PipPackage._deprecated()
return super().get_packages(pip_path=pip_path)

@classmethod
def get_outdated_packages(cls, pip_path="pip"):
PipPackage._deprecated()
return super().get_outdated_packages(pip_path=pip_path)

0 comments on commit c2af851

Please sign in to comment.