hbutils.testing.requires.cmd
Command availability checking utilities.
This module provides a small wrapper around the system which mechanism to
determine whether a given executable is available in the current environment.
It exposes a single public function for use in tests and environment checks.
The module contains the following main component:
cmdv()- Check whether an executable exists in the systemPATH.
Note
Internally, this module relies on hbutils.system.which(), which may be
deprecated in favor of shutil.which() in newer versions of the
dependency.
Example:
>>> from hbutils.testing.requires.cmd import cmdv
>>> cmdv('python')
True
>>> cmdv('not_installed')
False
__all__
- hbutils.testing.requires.cmd.__all__ = ['cmdv']
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
cmdv
- hbutils.testing.requires.cmd.cmdv(execfile: str) bool[source]
Check if the given command exists in this environment.
This function behaves like the
command -vcommand in Linux, checking whether an executable file is available in the system PATH. It is useful for verifying dependencies or determining platform-specific command availability.- Parameters:
execfile (str) – Executable file name to check, such as
python,bash, orapt-get.- Returns:
Trueif the executable file exists in the system PATH,Falseotherwise.- Return type:
bool
Example:
>>> from hbutils.testing import cmdv >>> cmdv('bash') True >>> cmdv('not_installed') False