diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e3b3286..6522727 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,14 +12,15 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] + python-version: ['3.10', '3.11', '3.12', '3.13', '3.14', '3.15'] fail-fast: false steps: - uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} + allow-prereleases: true - name: Install PIP run: | python -m pip install --upgrade pip diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e8c103..3685e1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Yellowbox Changelog ## NEXT +### Added +* added tests for python 3.15 (the `aerospike` extra is not installed on 3.15 until a compatible client is released) ### Internal +* upgraded pytest-xdist to v3 +* fixed lint errors from newer ruff versions * remove flakeyness around image building by building images with unique names ## 0.11.2 ### Fixed diff --git a/pyproject.toml b/pyproject.toml index 9c0f63d..7aa769b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,8 @@ pika = { version = "*", optional = true } # python 3.11 and lower use kafka-python, 3.12 and higher use confluent-kafka kafka-python = { version = "*", optional = true, python="<3.12" } confluent-kafka = { version = "*", optional = true, python=">=3.12" } -aerospike = { version = ">=10.0.1", optional = true } +# no cp315 wheel yet, and the sdist fails to build on python 3.15 +aerospike = { version = ">=10.0.1", optional = true, python = "<3.15" } # note that any version between 12.7.0 and 12.11.0 will not work azure-storage-blob = { version = ">=12.0.0", optional = true } @@ -55,7 +56,7 @@ websocket_client = "*" mypy = {version=">=1"} types-requests = "^2.25.0" types-redis = "^3.5.4" -pytest-xdist = "^2.1.0" +pytest-xdist = "^3.0.0" sphinx = {version="^6.1.3", python=">=3.12"} furo = {version="*", python=">=3.12"} pytest-asyncio = "^0.18.2" @@ -121,6 +122,7 @@ ignore = [ "COM812", # trailing comma, handled by black "PLR2004", # Magic value used in comparison "PLR0913", # Too many arguments to function call + "PLR0917", # Too many positional arguments (public signatures, same rationale as PLR0913) "PLR0912", # too many branches "PLR0911", # Too many return statements "PLR0915", # too many statements diff --git a/tests/extras/test_aerospike.py b/tests/extras/test_aerospike.py index c7ea3b7..1a5ecd5 100644 --- a/tests/extras/test_aerospike.py +++ b/tests/extras/test_aerospike.py @@ -1,4 +1,7 @@ -from pytest import fixture, mark +from pytest import fixture, importorskip, mark + +# the aerospike client is not installable on python 3.15 yet +importorskip("aerospike") from yellowbox.extras.aerospike import AerospikeService diff --git a/tests/extras/test_rabbit.py b/tests/extras/test_rabbit.py index 8ba9906..8b4961a 100644 --- a/tests/extras/test_rabbit.py +++ b/tests/extras/test_rabbit.py @@ -24,7 +24,8 @@ async def test_connection_works_async(docker_client): connection: BlockingConnection with rabbit.connection() as connection: channel = connection.channel() - channel.queue_declare("routing") + # recent RabbitMQ versions reject transient non-exclusive queues, so the queue must be durable + channel.queue_declare("routing", durable=True) channel.basic_publish("", "routing", body=b"hi there") sleep(1) @@ -50,7 +51,7 @@ def test_connection_works(docker_client, rabbit, q_name): connection: BlockingConnection with rabbit.connection() as connection: channel = connection.channel() - channel.queue_declare(q_name) + channel.queue_declare(q_name, durable=True) channel.basic_publish("", q_name, body=b"hi there") sleep(1) @@ -98,7 +99,7 @@ def assert_no_queues(rabbit: RabbitMQService): def test_reset_state(docker_client, rabbit, q_name): with rabbit.connection() as connection: channel = connection.channel() - channel.queue_declare(q_name) + channel.queue_declare(q_name, durable=True) channel.basic_consume(q_name, lambda: 1 / 0) # no-op rabbit.reset_state() assert_no_queues(rabbit) @@ -107,7 +108,7 @@ def test_reset_state(docker_client, rabbit, q_name): def test_reset_state_bad(docker_client, rabbit, q_name): with rabbit.connection() as connection: channel = connection.channel() - channel.queue_declare(q_name) + channel.queue_declare(q_name, durable=True) channel.basic_consume(q_name, lambda: 1 / 0) # no-op with raises(requests.HTTPError): rabbit.reset_state() @@ -116,7 +117,7 @@ def test_reset_state_bad(docker_client, rabbit, q_name): def test_reset_state_force(docker_client, rabbit, q_name): with rabbit.connection() as connection: channel = connection.channel() - channel.queue_declare(q_name) + channel.queue_declare(q_name, durable=True) channel.basic_consume(q_name, lambda: 1 / 0) # no-op rabbit.reset_state(force_queue_deletion=True) assert_no_queues(rabbit) diff --git a/yellowbox/extras/logstash.py b/yellowbox/extras/logstash.py index 6f71ce4..6e4ae63 100644 --- a/yellowbox/extras/logstash.py +++ b/yellowbox/extras/logstash.py @@ -113,7 +113,8 @@ def __init__(self, port: int = 0) -> None: # Avoiding a cyclic reference. _background = WeakMethod(self._background_thread) - self._thread = threading.Thread(target=lambda: _background()(), daemon=True) + # the lambda defers dereferencing the weakref until the thread runs + self._thread = threading.Thread(target=lambda: _background()(), daemon=True) # noqa: PLW0108 self._selector = selectors.DefaultSelector() diff --git a/yellowbox/extras/sql_base.py b/yellowbox/extras/sql_base.py index 105e21b..8660f48 100644 --- a/yellowbox/extras/sql_base.py +++ b/yellowbox/extras/sql_base.py @@ -36,7 +36,7 @@ def local_connection_string( self, dialect: str | AsDefault = as_default, driver: str | AsDefault | None = as_default, - options: ConnectionOptions | None | AsDefault = as_default, + options: ConnectionOptions | AsDefault | None = as_default, ): return self.owner.local_connection_string(dialect, driver, database=self.name, options=options) diff --git a/yellowbox/extras/webserver/http_request_capture.py b/yellowbox/extras/webserver/http_request_capture.py index 73251b8..4f9f237 100644 --- a/yellowbox/extras/webserver/http_request_capture.py +++ b/yellowbox/extras/webserver/http_request_capture.py @@ -135,7 +135,7 @@ def __init__( text: str | None = None, json: Any = _missing, json_submap: Mapping[str, Any] | None = None, - content_predicate: None | (Callable[[bytes], bool] | tuple[Callable[[bytes], Any], Any] | BodyValidator) = None, + content_predicate: (Callable[[bytes], bool] | tuple[Callable[[bytes], Any], Any] | BodyValidator) | None = None, ): """ Args: @@ -338,7 +338,7 @@ def assert_requested_with( text: str | None = None, json: Any = _missing, json_submap: Mapping[str, Any] | None = None, - content_predicate: None | (Callable[[bytes], bool] | tuple[Callable[[bytes], Any], Any] | BodyValidator) = None, + content_predicate: (Callable[[bytes], bool] | tuple[Callable[[bytes], Any], Any] | BodyValidator) | None = None, ): ... def assert_requested_with(self, expected: ExpectedHTTPRequest | None = None, **kwargs): @@ -426,7 +426,7 @@ def assert_any_request( text: str | None = None, json: Any = _missing, json_submap: Mapping[str, Any] | None = None, - content_predicate: None | (Callable[[bytes], bool] | tuple[Callable[[bytes], Any], Any] | BodyValidator) = None, + content_predicate: (Callable[[bytes], bool] | tuple[Callable[[bytes], Any], Any] | BodyValidator) | None = None, ): ... def assert_any_request(self, expected: ExpectedHTTPRequest | None = None, **kwargs):