Skip to content

asyncio unix events test doesn't restore mocked unix_events.can_use_pidfd #103780

Closed
@itamaro

Description

@itamaro

Bug report

in test_asyncio.test_unix_events.PolicyTest.test_get_default_child_watcher, unix_events.can_use_pidfd is mocked within the test body, but never restored to the original function.

this doesn't cause test failures during regular test runs, but during a refleak test run on MacOS it a AttributeError: module 'os' has no attribute 'pidfd_open' to be thrown (presumably due to another test using the non-mocked function in the second iteration).

repro:

./python.exe -m test test_asyncio -m '*.test_unix_events.*' -R 2:2
WARNING: Running tests with --huntrleaks/-R and less than 3 warmup repetitions can give false positives!
0:00:00 load avg: 3.79 Run tests sequentially
0:00:00 load avg: 3.79 [1/1] test_asyncio
beginning 4 repetitions
1234
.Process ForkProcess-10:
Traceback (most recent call last):
...
...
AttributeError: module 'os' has no attribute 'pidfd_open'
...
...

this can be fixed by patching instead of mocking in the test_get_default_child_watcher test (PR coming up).

Your environment

  • CPython versions tested on: main
  • Operating system and architecture: MacOS x86-64

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions