utils.py 386 B

123456789101112
  1. import pytest
  2. from ipython_genutils.py3compat import which
  3. def onlyif_cmds_exist(*commands):
  4. """
  5. Decorator to skip test when at least one of `commands` is not found.
  6. """
  7. for cmd in commands:
  8. if not which(cmd):
  9. return pytest.mark.skip("This test runs only if command '{0}' "
  10. "is installed".format(cmd))
  11. return lambda f: f