File: testutils.py

package info (click to toggle)
nbconvert 7.16.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,044 kB
  • sloc: python: 8,394; makefile: 199; javascript: 2
file content (13 lines) | stat: -rw-r--r-- 332 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
from shutil import which

import pytest


def onlyif_cmds_exist(*commands):
    """
    Decorator to skip test when at least one of `commands` is not found.
    """
    for cmd in commands:
        if not which(cmd):
            return pytest.mark.skip(f"This test runs only if command '{cmd}' is installed")
    return lambda f: f