Skip to content

Commit f677e54

Browse files
authored
pip check support in PipPackage module (#605)
1 parent ebb2bdf commit f677e54

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

test/test_modules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ def test_pip_package(host):
521521
outdated = host.pip_package.get_outdated_packages(pip_path="/v/bin/pip")["pytest"]
522522
assert outdated["current"] == pytest["version"]
523523
assert int(outdated["latest"].split(".")[0]) > 2
524+
assert host.pip_package.check().succeeded
524525

525526

526527
def test_environment_home(host):

testinfra/modules/pip.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ def _re_match(line, regexp):
2626
class PipPackage(InstanceModule):
2727
"""Test pip packages status and version"""
2828

29+
def check(self, pip_path="pip"):
30+
"""Verify installed packages have compatible dependencies.
31+
32+
>>> cmd = host.pip_package.check()
33+
>>> cmd.rc
34+
0
35+
>>> cmd.stdout
36+
No broken requirements found.
37+
38+
Can only be used if `pip check`_ command is available,
39+
for pip versions >= 9.0.0_.
40+
41+
.. _pip check: https://pip.pypa.io/en/stable/reference/pip_check/
42+
.. _9.0.0: https://pip.pypa.io/en/stable/news/#id526
43+
"""
44+
cmd = "{} check".format(pip_path)
45+
return self.run_expect([0, 1], cmd)
46+
2947
def get_packages(self, pip_path="pip"):
3048
"""Get all installed packages and versions returned by `pip list`:
3149

0 commit comments

Comments
 (0)