Skip to content

Commit

Permalink
pip check support in PipPackage module (#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
romainx committed Mar 8, 2021
1 parent ebb2bdf commit f677e54
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ def test_pip_package(host):
outdated = host.pip_package.get_outdated_packages(pip_path="/v/bin/pip")["pytest"]
assert outdated["current"] == pytest["version"]
assert int(outdated["latest"].split(".")[0]) > 2
assert host.pip_package.check().succeeded


def test_environment_home(host):
Expand Down
18 changes: 18 additions & 0 deletions testinfra/modules/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ def _re_match(line, regexp):
class PipPackage(InstanceModule):
"""Test pip packages status and version"""

def check(self, pip_path="pip"):
"""Verify installed packages have compatible dependencies.
>>> cmd = host.pip_package.check()
>>> cmd.rc
0
>>> cmd.stdout
No broken requirements found.
Can only be used if `pip check`_ command is available,
for pip versions >= 9.0.0_.
.. _pip check: https://pip.pypa.io/en/stable/reference/pip_check/
.. _9.0.0: https://pip.pypa.io/en/stable/news/#id526
"""
cmd = "{} check".format(pip_path)
return self.run_expect([0, 1], cmd)

def get_packages(self, pip_path="pip"):
"""Get all installed packages and versions returned by `pip list`:
Expand Down

0 comments on commit f677e54

Please sign in to comment.