# HG changeset patch # User Manuel Jacob # Date 2020-03-11 04:41:02 # Node ID aa0e1341457b04d684aa09912d35137103b1e510 # Parent 3265c92f7d13a7fc20dfc4a86c68d7bd26e60d75 tests: check availability of pyflakes by trying to import pyflakes module Since e397c6d74652, we use the pyflakes module instead of the pyflakes executable. As was pointed out during the review, the hghave check can be rewritten to try to import the pyflakes module instead of spawning a new subprocess. diff --git a/tests/hghave.py b/tests/hghave.py --- a/tests/hghave.py +++ b/tests/hghave.py @@ -574,11 +574,14 @@ def has_root(): @check("pyflakes", "Pyflakes python linter") def has_pyflakes(): - return matchoutput( - "sh -c \"echo 'import re' 2>&1 | $PYTHON -m pyflakes\"", - br":1: 're' imported but unused", - True, - ) + try: + import pyflakes + + pyflakes.__version__ + except ImportError: + return False + else: + return True @check("pylint", "Pylint python linter")