Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_no_executable_raises_error():
check_pwd()
with mock.patch.dict(os.environ, {'PATH': ''}, clear=True):
with pytest.raises(ExecutableNotFoundError):
AHK()
def __init__(self, executable_path: str='', **kwargs):
"""
:param executable_path: the path to the AHK executable.
Defaults to environ['AHK_PATH'] if not explicitly provided
If environment variable not present, tries to look for 'AutoHotkey.exe' or 'AutoHotkeyA32.exe' with shutil.which
:param keep_scripts:
:raises ExecutableNotFound: if AHK executable is not provided and cannot be found in environment variables or PATH
"""
if not executable_path:
executable_path = os.environ.get('AHK_PATH') or which('AutoHotkey.exe') or which('AutoHotkeyA32.exe')
if not executable_path:
raise ExecutableNotFoundError('Could not find AutoHotkey.exe on PATH. '
'Provide the absolute path with the `executable_path` keyword argument '
'or in the AHK_PATH environment variable.')
self.executable_path = executable_path
templates_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'templates')
self.env = Environment(
loader=FileSystemLoader(templates_path),
autoescape=False,
trim_blocks=True
)