Skip to content

Commit

Permalink
🐛 Fix passing args @ get_signal_name() shim (#32)
Browse files Browse the repository at this point in the history
This also adds a test for it.
  • Loading branch information
webknjaz authored Feb 12, 2024
1 parent b03d662 commit 2c52d6d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/module_utils/python_runtime_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def __init__( # noqa: WPS612
super(TimeoutError, self).__init__(errno, *args, **kwargs)


def get_signal_name(signal_constant):
def get_signal_name(signal_constant): # type: (int | signal.Signals) -> str
try:
return signal.Signals(signal).name # Python 3
return signal.Signals(signal_constant).name # Python 3
except AttributeError:
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
__metaclass__ = type

import errno
import signal
import sys

import pytest

from ansible_collections.samdoran.macos.plugins.module_utils.python_runtime_compat import get_signal_name
from ansible_collections.samdoran.macos.plugins.module_utils.python_runtime_compat import shlex_join
from ansible_collections.samdoran.macos.plugins.module_utils.python_runtime_compat import TimeoutError

Expand Down Expand Up @@ -45,3 +47,8 @@ def test_timeout_error_is_oserror():
def test_timeout_error_errno():
"""Test :exc:`TimeoutError`'s ``errno`` property's ``ETIMEDOUT``."""
assert TimeoutError().errno in (errno.ETIMEDOUT, None) # noqa: WPS510


def test_get_signal_name(): # type: () -> None
"""Verify :py:func:`get_signal_name`'s advertised behavior."""
assert 'SIGSEGV' == get_signal_name(signal.SIGSEGV)

0 comments on commit 2c52d6d

Please sign in to comment.