From 56d1d95eb3b5cfd1969049937d580e07a119e9a7 Mon Sep 17 00:00:00 2001 From: William Barnhart Date: Thu, 29 Jun 2023 14:51:26 -0400 Subject: [PATCH 01/11] Skip failing tests on PyPy for now --- .github/workflows/python-package.yml | 7 +++---- tests/unit/test_streams.py | 7 +++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 5670989c2..ecbee425b 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -48,10 +48,9 @@ jobs: python-version: ['3.8', '3.9', '3.10', '3.11'] use-cython: ['true', 'false'] experimental: [false] -# include: -# - python-version: pypy3.9 -# experimental: true -# use-cython: 'false' + include: + - python-version: pypy3.9 + experimental: true # - python-version: ~3.12.0-0 # experimental: true # use-cython: 'false' diff --git a/tests/unit/test_streams.py b/tests/unit/test_streams.py index 1a9c03035..eb68ce88e 100644 --- a/tests/unit/test_streams.py +++ b/tests/unit/test_streams.py @@ -1,4 +1,5 @@ import asyncio +import platform from collections import defaultdict from unittest.mock import Mock, patch @@ -122,6 +123,9 @@ async def test_echo(self, *, stream, app): await echoing("val") channel.send.assert_called_once_with(value="val") + @pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" + ) @pytest.mark.asyncio @pytest.mark.allow_lingering_tasks(count=1) async def test_aiter_tracked(self, *, stream, app): @@ -137,6 +141,9 @@ async def test_aiter_tracked(self, *, stream, app): else: event.ack.assert_called_once_with() + @pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" + ) @pytest.mark.asyncio @pytest.mark.allow_lingering_tasks(count=1) async def test_aiter_tracked__CancelledError(self, *, stream, app): From 3da6d5b423c5cb17e1307400d562d1ea0cf9d874 Mon Sep 17 00:00:00 2001 From: William Barnhart Date: Thu, 29 Jun 2023 14:55:51 -0400 Subject: [PATCH 02/11] use move pypy3.9 into main tests --- .github/workflows/python-package.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index ecbee425b..0c0d2aa68 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -45,12 +45,10 @@ jobs: # for example if a test fails only when Cython is enabled fail-fast: false matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', 'pypy3.9'] use-cython: ['true', 'false'] experimental: [false] - include: - - python-version: pypy3.9 - experimental: true +# include: # - python-version: ~3.12.0-0 # experimental: true # use-cython: 'false' From 1e1b8cecd5c7e9edf9ad0a6524131b7ce90f2269 Mon Sep 17 00:00:00 2001 From: William Barnhart Date: Thu, 29 Jun 2023 15:13:50 -0400 Subject: [PATCH 03/11] never mind pypy is experimental then --- .github/workflows/python-package.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 0c0d2aa68..657c62578 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -45,13 +45,16 @@ jobs: # for example if a test fails only when Cython is enabled fail-fast: false matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', 'pypy3.9'] + python-version: ['3.8', '3.9', '3.10', '3.11'] use-cython: ['true', 'false'] experimental: [false] -# include: -# - python-version: ~3.12.0-0 -# experimental: true -# use-cython: 'false' + include: + - python-version: 'pypy3.9' + use-cython: ['true', 'false'] + experimental: true +# - python-version: ~3.12.0-0 +# experimental: true +# use-cython: 'false' env: USE_CYTHON: ${{ matrix.use-cython }} continue-on-error: ${{ matrix.experimental }} From 6ee2ea191605bed8ee7338653a6ebdbf0a719fe8 Mon Sep 17 00:00:00 2001 From: William Barnhart Date: Thu, 29 Jun 2023 15:15:43 -0400 Subject: [PATCH 04/11] skip meticulous tests on pypy --- .../assignor/test_copartitioned_assignor.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/meticulous/assignor/test_copartitioned_assignor.py b/tests/meticulous/assignor/test_copartitioned_assignor.py index 8179012e1..05c2f0ce8 100644 --- a/tests/meticulous/assignor/test_copartitioned_assignor.py +++ b/tests/meticulous/assignor/test_copartitioned_assignor.py @@ -1,7 +1,9 @@ import copy +import platform from collections import Counter from typing import MutableMapping +import pytest from hypothesis import assume, given, settings from hypothesis.strategies import integers @@ -77,6 +79,9 @@ def client_removal_sticky( return True +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @given( partitions=integers(min_value=0, max_value=256), replicas=integers(min_value=0, max_value=64), @@ -95,6 +100,9 @@ def test_fresh_assignment(partitions, replicas, num_clients): assert is_valid(new_assignments, partitions, replicas) +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @given( partitions=integers(min_value=0, max_value=256), replicas=integers(min_value=0, max_value=64), @@ -131,6 +139,9 @@ def test_add_new_clients(partitions, replicas, num_clients, num_additional_clien assert clients_balanced(new_assignments) +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @given( partitions=integers(min_value=0, max_value=256), replicas=integers(min_value=0, max_value=64), From d31f428c58b68741fdfd72d9b8d7e08abfd09491 Mon Sep 17 00:00:00 2001 From: William Barnhart Date: Thu, 29 Jun 2023 15:28:14 -0400 Subject: [PATCH 05/11] no cython w/pypy for now --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 657c62578..bcc94a2c4 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -50,7 +50,7 @@ jobs: experimental: [false] include: - python-version: 'pypy3.9' - use-cython: ['true', 'false'] + use-cython: false experimental: true # - python-version: ~3.12.0-0 # experimental: true From af2484037f5805354e163e88753eb97a1a3207a6 Mon Sep 17 00:00:00 2001 From: William Barnhart Date: Thu, 29 Jun 2023 16:01:36 -0400 Subject: [PATCH 06/11] skip janky tests on pypy --- tests/functional/test_streams.py | 42 +++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/tests/functional/test_streams.py b/tests/functional/test_streams.py index 95185cbeb..a4d092a1c 100644 --- a/tests/functional/test_streams.py +++ b/tests/functional/test_streams.py @@ -1,4 +1,6 @@ import asyncio +import platform +import pytest from copy import copy from unittest.mock import Mock, patch @@ -39,6 +41,9 @@ def _prepare_app(app): return app +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @pytest.mark.asyncio @pytest.mark.allow_lingering_tasks(count=1) async def test_simple(app, loop): @@ -50,6 +55,9 @@ async def test_simple(app, loop): assert await channel_empty(stream.channel) +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @pytest.mark.asyncio async def test_async_iterator(app): async with new_stream(app) as stream: @@ -64,6 +72,9 @@ async def test_async_iterator(app): assert await channel_empty(stream.channel) +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @pytest.mark.asyncio async def test_throw(app): async with new_stream(app) as stream: @@ -75,6 +86,9 @@ async def test_throw(app): await anext(streamit) +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @pytest.mark.asyncio async def test_enumerate(app): async with new_stream(app) as stream: @@ -89,6 +103,9 @@ async def test_enumerate(app): assert await channel_empty(stream.channel) +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @pytest.mark.asyncio async def test_items(app): async with new_stream(app) as stream: @@ -104,6 +121,9 @@ async def test_items(app): assert await channel_empty(stream.channel) +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @pytest.mark.asyncio async def test_through(app): app._attachments.enabled = False @@ -236,6 +256,9 @@ async def test_stream_filter_acks_filtered_out_messages(app, event_loop): assert len(app.consumer.unacked) == 0 +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @pytest.mark.asyncio async def test_acks_filtered_out_messages_when_using_take(app, event_loop): """ @@ -259,7 +282,9 @@ async def test_acks_filtered_out_messages_when_using_take(app, event_loop): acked = [m.acked for m in messages if m.acked] assert len(acked) == len(initial_values) - +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @pytest.mark.asyncio async def test_events(app): async with new_stream(app) as stream: @@ -414,6 +439,9 @@ async def _start_stop_stream(stream): await stream.stop() +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @pytest.mark.asyncio async def test_ack(app): async with new_stream(app) as s: @@ -439,6 +467,9 @@ async def test_ack(app): assert not event.message.refcount +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @pytest.mark.asyncio async def test_noack(app): async with new_stream(app) as s: @@ -459,6 +490,9 @@ async def test_noack(app): event.ack.assert_not_called() +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @pytest.mark.asyncio async def test_acked_when_raising(app): async with new_stream(app) as s: @@ -496,6 +530,9 @@ async def test_acked_when_raising(app): assert not event2.message.refcount +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @pytest.mark.asyncio @pytest.mark.allow_lingering_tasks(count=1) async def test_maybe_forward__when_event(app): @@ -508,6 +545,9 @@ async def test_maybe_forward__when_event(app): s.channel.send.assert_not_called() +@pytest.mark.skipif( + platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" +) @pytest.mark.asyncio async def test_maybe_forward__when_concrete_value(app): s = new_stream(app) From 6e1ce9fce4f5b7ea576568474edee6788380ff15 Mon Sep 17 00:00:00 2001 From: William Barnhart Date: Thu, 29 Jun 2023 16:01:50 -0400 Subject: [PATCH 07/11] lint --- tests/functional/test_streams.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/test_streams.py b/tests/functional/test_streams.py index a4d092a1c..5061d8673 100644 --- a/tests/functional/test_streams.py +++ b/tests/functional/test_streams.py @@ -1,6 +1,5 @@ import asyncio import platform -import pytest from copy import copy from unittest.mock import Mock, patch @@ -282,6 +281,7 @@ async def test_acks_filtered_out_messages_when_using_take(app, event_loop): acked = [m.acked for m in messages if m.acked] assert len(acked) == len(initial_values) + @pytest.mark.skipif( platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" ) From 6a3a36c9c6f4a212e2e8f5513ef5ed8261984bb9 Mon Sep 17 00:00:00 2001 From: William Barnhart Date: Thu, 29 Jun 2023 16:02:50 -0400 Subject: [PATCH 08/11] rename workflow --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index bcc94a2c4..2a358b591 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,5 +1,5 @@ --- -name: Test Python library +name: CI/CD on: push: branches: [master] From cc4ec54cecc57347f041eec811e8c9288b613cf5 Mon Sep 17 00:00:00 2001 From: William Barnhart Date: Thu, 29 Jun 2023 17:25:06 -0400 Subject: [PATCH 09/11] add asyncio_mode = "auto" to pyproject.toml --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 1c86fac64..043c42765 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ ignore_missing_imports = true disallow_untyped_defs = true [tool.pytest.ini_options] +asyncio_mode = "auto" minversion = "6.0" addopts = [ "--cov-report=term-missing:skip-covered", From c955ff01cf42dea2839bfa66e8966ac55e194ffa Mon Sep 17 00:00:00 2001 From: William Barnhart Date: Thu, 29 Jun 2023 17:36:45 -0400 Subject: [PATCH 10/11] undo disabled tests in functional test_streams.py --- tests/functional/test_streams.py | 40 -------------------------------- 1 file changed, 40 deletions(-) diff --git a/tests/functional/test_streams.py b/tests/functional/test_streams.py index 5061d8673..95185cbeb 100644 --- a/tests/functional/test_streams.py +++ b/tests/functional/test_streams.py @@ -1,5 +1,4 @@ import asyncio -import platform from copy import copy from unittest.mock import Mock, patch @@ -40,9 +39,6 @@ def _prepare_app(app): return app -@pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" -) @pytest.mark.asyncio @pytest.mark.allow_lingering_tasks(count=1) async def test_simple(app, loop): @@ -54,9 +50,6 @@ async def test_simple(app, loop): assert await channel_empty(stream.channel) -@pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" -) @pytest.mark.asyncio async def test_async_iterator(app): async with new_stream(app) as stream: @@ -71,9 +64,6 @@ async def test_async_iterator(app): assert await channel_empty(stream.channel) -@pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" -) @pytest.mark.asyncio async def test_throw(app): async with new_stream(app) as stream: @@ -85,9 +75,6 @@ async def test_throw(app): await anext(streamit) -@pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" -) @pytest.mark.asyncio async def test_enumerate(app): async with new_stream(app) as stream: @@ -102,9 +89,6 @@ async def test_enumerate(app): assert await channel_empty(stream.channel) -@pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" -) @pytest.mark.asyncio async def test_items(app): async with new_stream(app) as stream: @@ -120,9 +104,6 @@ async def test_items(app): assert await channel_empty(stream.channel) -@pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" -) @pytest.mark.asyncio async def test_through(app): app._attachments.enabled = False @@ -255,9 +236,6 @@ async def test_stream_filter_acks_filtered_out_messages(app, event_loop): assert len(app.consumer.unacked) == 0 -@pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" -) @pytest.mark.asyncio async def test_acks_filtered_out_messages_when_using_take(app, event_loop): """ @@ -282,9 +260,6 @@ async def test_acks_filtered_out_messages_when_using_take(app, event_loop): assert len(acked) == len(initial_values) -@pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" -) @pytest.mark.asyncio async def test_events(app): async with new_stream(app) as stream: @@ -439,9 +414,6 @@ async def _start_stop_stream(stream): await stream.stop() -@pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" -) @pytest.mark.asyncio async def test_ack(app): async with new_stream(app) as s: @@ -467,9 +439,6 @@ async def test_ack(app): assert not event.message.refcount -@pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" -) @pytest.mark.asyncio async def test_noack(app): async with new_stream(app) as s: @@ -490,9 +459,6 @@ async def test_noack(app): event.ack.assert_not_called() -@pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" -) @pytest.mark.asyncio async def test_acked_when_raising(app): async with new_stream(app) as s: @@ -530,9 +496,6 @@ async def test_acked_when_raising(app): assert not event2.message.refcount -@pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" -) @pytest.mark.asyncio @pytest.mark.allow_lingering_tasks(count=1) async def test_maybe_forward__when_event(app): @@ -545,9 +508,6 @@ async def test_maybe_forward__when_event(app): s.channel.send.assert_not_called() -@pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" -) @pytest.mark.asyncio async def test_maybe_forward__when_concrete_value(app): s = new_stream(app) From f756906a5934d4881c66811ed718dbffc4b0d855 Mon Sep 17 00:00:00 2001 From: William Barnhart Date: Thu, 29 Jun 2023 18:08:39 -0400 Subject: [PATCH 11/11] enable regular stream testing for unit tests --- tests/unit/test_streams.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/unit/test_streams.py b/tests/unit/test_streams.py index eb68ce88e..1a9c03035 100644 --- a/tests/unit/test_streams.py +++ b/tests/unit/test_streams.py @@ -1,5 +1,4 @@ import asyncio -import platform from collections import defaultdict from unittest.mock import Mock, patch @@ -123,9 +122,6 @@ async def test_echo(self, *, stream, app): await echoing("val") channel.send.assert_called_once_with(value="val") - @pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" - ) @pytest.mark.asyncio @pytest.mark.allow_lingering_tasks(count=1) async def test_aiter_tracked(self, *, stream, app): @@ -141,9 +137,6 @@ async def test_aiter_tracked(self, *, stream, app): else: event.ack.assert_called_once_with() - @pytest.mark.skipif( - platform.python_implementation() == "PyPy", reason="Not yet supported on PyPy" - ) @pytest.mark.asyncio @pytest.mark.allow_lingering_tasks(count=1) async def test_aiter_tracked__CancelledError(self, *, stream, app):