Skip to content

Commit fba1ae8

Browse files
committed
Enable asyncio compat tests for subinterpreters
- Remove subinterpreter skip from py_asyncio_compat_SUITE - Fix test_create_unix_server_existing_path to work with both ErlangEventLoop (auto-unlinks) and asyncio (manual unlink)
1 parent a79b522 commit fba1ae8

2 files changed

Lines changed: 26 additions & 24 deletions

File tree

priv/tests/test_unix.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ async def main():
8080
self.assertEqual(len(connections), 1)
8181

8282
def test_create_unix_server_existing_path(self):
83-
"""Test that server removes existing socket file."""
83+
"""Test that server can be created at path with existing file.
84+
85+
ErlangEventLoop auto-removes existing files. For asyncio, we
86+
manually remove first to test the same underlying behavior.
87+
"""
8488
with tempfile.TemporaryDirectory() as tmpdir:
8589
path = os.path.join(tmpdir, 'test.sock')
8690

@@ -89,7 +93,12 @@ def test_create_unix_server_existing_path(self):
8993
f.write('test')
9094

9195
async def main():
92-
# Should replace the file
96+
# For standard asyncio, manually remove the file first
97+
# (ErlangEventLoop does this automatically)
98+
loop_class = type(self.loop).__name__
99+
if 'Erlang' not in loop_class:
100+
os.unlink(path)
101+
93102
server = await self.loop.create_unix_server(
94103
asyncio.Protocol, path
95104
)

test/py_asyncio_compat_SUITE.erl

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -99,28 +99,21 @@ groups() ->
9999
].
100100

101101
init_per_suite(Config) ->
102-
%% Skip asyncio compat tests when subinterpreters are in use
103-
%% The event loop integration is not yet compatible with OWN_GIL subinterpreters
104-
case py_nif:subinterp_supported() of
105-
true ->
106-
{skip, "asyncio compat tests not supported with subinterpreters"};
107-
false ->
108-
case application:ensure_all_started(erlang_python) of
109-
{ok, _} ->
110-
{ok, _} = py:start_contexts(),
111-
%% Wait for event loop to be fully initialized
112-
case wait_for_event_loop(5000) of
113-
ok ->
114-
%% Set up Python path for tests
115-
PrivDir = code:priv_dir(erlang_python),
116-
ok = setup_python_path(PrivDir),
117-
[{priv_dir, PrivDir} | Config];
118-
{error, Reason} ->
119-
ct:fail({event_loop_not_ready, Reason})
120-
end;
121-
{error, {App, Reason}} ->
122-
ct:fail({failed_to_start, App, Reason})
123-
end
102+
case application:ensure_all_started(erlang_python) of
103+
{ok, _} ->
104+
{ok, _} = py:start_contexts(),
105+
%% Wait for event loop to be fully initialized
106+
case wait_for_event_loop(5000) of
107+
ok ->
108+
%% Set up Python path for tests
109+
PrivDir = code:priv_dir(erlang_python),
110+
ok = setup_python_path(PrivDir),
111+
[{priv_dir, PrivDir} | Config];
112+
{error, Reason} ->
113+
ct:fail({event_loop_not_ready, Reason})
114+
end;
115+
{error, {App, Reason}} ->
116+
ct:fail({failed_to_start, App, Reason})
124117
end.
125118

126119
end_per_suite(_Config) ->

0 commit comments

Comments
 (0)