Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion tests/test_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ def _assert_tick_is_aligned(


# https://github.com/frequenz-floss/frequenz-channels-python/issues/405
@pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning")
@pytest.mark.filterwarnings("ignore::ResourceWarning")
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning filter pattern has been changed from a socket-specific pattern to a BaseEventLoop cleanup pattern. Consider documenting why this change was necessary (e.g., different warning signatures on ARM64 vs x86_64) to help future maintainers understand the architecture-specific behavior.

Suggested change
@pytest.mark.filterwarnings("ignore::ResourceWarning")
@pytest.mark.filterwarnings("ignore::ResourceWarning")
# NOTE: The warning filter pattern below was changed from a socket-specific pattern
# to a BaseEventLoop cleanup pattern because different architectures (e.g., ARM64 vs x86_64)
# and Python versions emit different warning signatures for event loop cleanup.
# This filter suppresses ResourceWarnings from BaseEventLoop.__del__ in a platform-agnostic way.

Copilot uses AI. Check for mistakes.
@pytest.mark.filterwarnings(
r"default:Exception ignored in. <socket\.socket.*:pytest.PytestUnraisableExceptionWarning"
"ignore:Exception ignored in.* <function BaseEventLoop.__del__.*"
)
@hypothesis.given(**_calculate_next_tick_time_args)
def test_policy_trigger_all_missed(
Expand Down Expand Up @@ -103,6 +105,12 @@ def test_policy_trigger_all_missed_examples() -> None:
)


# https://github.com/frequenz-floss/frequenz-channels-python/issues/405
@pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning")
@pytest.mark.filterwarnings("ignore::ResourceWarning")
@pytest.mark.filterwarnings(
"ignore:Exception ignored in.* <function BaseEventLoop.__del__.*"
)
Comment on lines +108 to +113
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same set of warning filters is duplicated across multiple test functions. Consider extracting these into a pytest fixture or a custom decorator to reduce duplication and make future updates easier to maintain.

Copilot uses AI. Check for mistakes.
@hypothesis.given(**_calculate_next_tick_time_args)
def test_policy_skip_missed_and_resync(
now: int, scheduled_tick_time: int, interval: int
Expand Down Expand Up @@ -144,6 +152,12 @@ def test_policy_skip_missed_and_resync_examples() -> None:
)


# https://github.com/frequenz-floss/frequenz-channels-python/issues/405
@pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning")
@pytest.mark.filterwarnings("ignore::ResourceWarning")
@pytest.mark.filterwarnings(
"ignore:Exception ignored in.* <function BaseEventLoop.__del__.*"
)
@hypothesis.given(
tolerance=st.floats(
min_value=timedelta.min.total_seconds(),
Expand All @@ -159,6 +173,12 @@ def test_policy_skip_missed_and_drift_invalid_tolerance(tolerance: float) -> Non
SkipMissedAndDrift(delay_tolerance=timedelta(microseconds=tolerance))


# https://github.com/frequenz-floss/frequenz-channels-python/issues/405
@pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning")
@pytest.mark.filterwarnings("ignore::ResourceWarning")
@pytest.mark.filterwarnings(
"ignore:Exception ignored in.* <function BaseEventLoop.__del__.*"
)
@hypothesis.given(
tolerance=st.floats(
min_value=0,
Expand Down