Skip tests with multiprocessing start method fork on windows (#468)

This commit is contained in:
ChristofKaufmann
2023-04-25 05:38:43 -07:00
committed by GitHub
parent 4b7eb729ea
commit d8b32b2cc3
2 changed files with 15 additions and 0 deletions

View File

@@ -23,6 +23,11 @@ from tests.spaces.utils import TESTING_SPACES, TESTING_SPACES_IDS
) )
def test_shared_memory_create_read_write(space, num, ctx): def test_shared_memory_create_read_write(space, num, ctx):
"""Test the shared memory functions, create, read and write for all of the testing spaces.""" """Test the shared memory functions, create, read and write for all of the testing spaces."""
if ctx not in mp.get_all_start_methods():
pytest.skip(
f"Multiprocessing start method {ctx} not available on this platform."
)
ctx = mp if ctx is None else mp.get_context(ctx) ctx = mp if ctx is None else mp.get_context(ctx)
samples = [space.sample() for _ in range(num)] samples = [space.sample() for _ in range(num)]

View File

@@ -50,6 +50,11 @@ expected_types = [
"ctx", [None, "fork", "spawn"], ids=["default", "fork", "spawn"] "ctx", [None, "fork", "spawn"], ids=["default", "fork", "spawn"]
) )
def test_create_shared_memory(space, expected_type, n, ctx): def test_create_shared_memory(space, expected_type, n, ctx):
if ctx not in mp.get_all_start_methods():
pytest.skip(
f"Multiprocessing start method {ctx} not available on this platform."
)
def assert_nested_type(lhs, rhs, n): def assert_nested_type(lhs, rhs, n):
assert type(lhs) == type(rhs) assert type(lhs) == type(rhs)
if isinstance(lhs, (list, tuple)): if isinstance(lhs, (list, tuple)):
@@ -81,6 +86,11 @@ def test_create_shared_memory(space, expected_type, n, ctx):
) )
@pytest.mark.parametrize("space", custom_spaces) @pytest.mark.parametrize("space", custom_spaces)
def test_create_shared_memory_custom_space(n, ctx, space): def test_create_shared_memory_custom_space(n, ctx, space):
if ctx not in mp.get_all_start_methods():
pytest.skip(
f"Multiprocessing start method {ctx} not available on this platform."
)
ctx = mp if (ctx is None) else mp.get_context(ctx) ctx = mp if (ctx is None) else mp.get_context(ctx)
with pytest.raises(CustomSpaceError): with pytest.raises(CustomSpaceError):
create_shared_memory(space, n=n, ctx=ctx) create_shared_memory(space, n=n, ctx=ctx)