Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v4
with:
Expand Down
5 changes: 5 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


# Configure pytest-asyncio
pytest_plugins = ('pytest_asyncio',)

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ crypto = ["pycryptodome"]
vcdiff = ["vcdiff-decoder>=0.1.0,<0.2.0"]
dev = [
"pytest>=7.1,<8.0",
"pytest-asyncio>=0.21.0,<0.23.0; python_version=='3.7'",
"pytest-asyncio>=0.23.0,<1.0.0; python_version>='3.8'",
"mock>=4.0.3,<5.0.0",
"pytest-cov>=2.4,<3.0",
"ruff>=0.14.0,<1.0.0",
Expand Down Expand Up @@ -91,6 +93,7 @@ packages = ["ably"]

[tool.pytest.ini_options]
timeout = 30
asyncio_mode = "auto"

[[tool.uv.index]]
name = "experimental"
Expand Down
15 changes: 6 additions & 9 deletions test/ably/conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import asyncio

import pytest
import pytest_asyncio

from test.ably.testapp import TestApp


@pytest.fixture(scope='session', autouse=True)
def event_loop():
loop = asyncio.get_event_loop_policy().new_event_loop()
loop.run_until_complete(TestApp.get_test_vars())
yield loop
loop.run_until_complete(TestApp.clear_test_vars())
@pytest_asyncio.fixture(scope='session', autouse=True)
async def test_app_setup():
await TestApp.get_test_vars()
yield
await TestApp.clear_test_vars()
5 changes: 4 additions & 1 deletion test/ably/realtime/eventemitter_test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import asyncio

import pytest

from ably.realtime.connection import ConnectionState
from test.ably.testapp import TestApp
from test.ably.utils import BaseAsyncTestCase


class TestEventEmitter(BaseAsyncTestCase):
async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.test_vars = await TestApp.get_test_vars()

async def test_event_listener_error(self):
Expand Down
3 changes: 2 additions & 1 deletion test/ably/realtime/realtimechannel_publish_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
class TestRealtimeChannelPublish(BaseAsyncTestCase):
"""Tests for RTN7 spec - Message acknowledgment"""

async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.test_vars = await TestApp.get_test_vars()

# RTN7a - Basic ACK/NACK functionality
Expand Down
3 changes: 2 additions & 1 deletion test/ably/realtime/realtimechannel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@


class TestRealtimeChannel(BaseAsyncTestCase):
async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.test_vars = await TestApp.get_test_vars()
self.valid_key_format = "api:key"

Expand Down
5 changes: 4 additions & 1 deletion test/ably/realtime/realtimechannel_vcdiff_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import asyncio
import json

import pytest

from ably import AblyVCDiffDecoder
from ably.realtime.connection import ConnectionState
from ably.realtime.realtime_channel import ChannelOptions
Expand Down Expand Up @@ -31,7 +33,8 @@ def decode(self, delta: bytes, base: bytes) -> bytes:


class TestRealtimeChannelVCDiff(BaseAsyncTestCase):
async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.test_vars = await TestApp.get_test_vars()
self.valid_key_format = "api:key"

Expand Down
3 changes: 2 additions & 1 deletion test/ably/realtime/realtimeconnection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@


class TestRealtimeConnection(BaseAsyncTestCase):
async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.test_vars = await TestApp.get_test_vars()
self.valid_key_format = "api:key"

Expand Down
3 changes: 2 additions & 1 deletion test/ably/realtime/realtimeinit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@


class TestRealtimeInit(BaseAsyncTestCase):
async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.test_vars = await TestApp.get_test_vars()
self.valid_key_format = "api:key"

Expand Down
5 changes: 4 additions & 1 deletion test/ably/realtime/realtimeresume_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import asyncio

import pytest

from ably.realtime.connection import ConnectionState
from ably.realtime.realtime_channel import ChannelState
from ably.transport.websockettransport import ProtocolMessageAction
Expand All @@ -22,7 +24,8 @@ def on_message(_):


class TestRealtimeResume(BaseAsyncTestCase):
async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.test_vars = await TestApp.get_test_vars()
self.valid_key_format = "api:key"

Expand Down
28 changes: 14 additions & 14 deletions test/ably/rest/encoders_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from unittest import mock

import msgpack
import pytest

from ably import CipherParams
from ably.types.message import Message
Expand All @@ -21,10 +22,10 @@


class TestTextEncodersNoEncryption(BaseAsyncTestCase):
async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.ably = await TestApp.get_ably_rest(use_binary_protocol=False)

async def asyncTearDown(self):
yield
await self.ably.close()

async def test_text_utf8(self):
Expand Down Expand Up @@ -143,12 +144,11 @@ def test_decode_with_invalid_encoding(self):


class TestTextEncodersEncryption(BaseAsyncTestCase):
async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.ably = await TestApp.get_ably_rest(use_binary_protocol=False)
self.cipher_params = CipherParams(secret_key='keyfordecrypt_16',
algorithm='aes')

async def asyncTearDown(self):
self.cipher_params = CipherParams(secret_key='keyfordecrypt_16', algorithm='aes')
yield
await self.ably.close()

def decrypt(self, payload, options=None):
Expand Down Expand Up @@ -257,10 +257,10 @@ async def test_with_json_list_data_decode(self):

class TestBinaryEncodersNoEncryption(BaseAsyncTestCase):

async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.ably = await TestApp.get_ably_rest()

async def asyncTearDown(self):
yield
await self.ably.close()

def decode(self, data):
Expand Down Expand Up @@ -348,11 +348,11 @@ async def test_with_json_list_data_decode(self):

class TestBinaryEncodersEncryption(BaseAsyncTestCase):

async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.ably = await TestApp.get_ably_rest()
self.cipher_params = CipherParams(secret_key='keyfordecrypt_16', algorithm='aes')

async def asyncTearDown(self):
yield
await self.ably.close()

def decrypt(self, payload, options=None):
Expand Down
24 changes: 13 additions & 11 deletions test/ably/rest/restauth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

# does not make any request, no need to vary by protocol
class TestAuth(BaseAsyncTestCase):
async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.test_vars = await TestApp.get_test_vars()

def test_auth_init_key_only(self):
Expand Down Expand Up @@ -167,11 +168,11 @@ def test_with_default_token_params(self):

class TestAuthAuthorize(BaseAsyncTestCase, metaclass=VaryByProtocolTestsMetaclass):

async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.ably = await TestApp.get_ably_rest()
self.test_vars = await TestApp.get_test_vars()

async def asyncTearDown(self):
yield
await self.ably.close()

def per_protocol_setup(self, use_binary_protocol):
Expand Down Expand Up @@ -322,7 +323,8 @@ async def test_client_id_precedence(self):

class TestRequestToken(BaseAsyncTestCase, metaclass=VaryByProtocolTestsMetaclass):

async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.test_vars = await TestApp.get_test_vars()

def per_protocol_setup(self, use_binary_protocol):
Expand Down Expand Up @@ -480,7 +482,8 @@ async def test_client_id_null_until_auth(self):

class TestRenewToken(BaseAsyncTestCase):

async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.test_vars = await TestApp.get_test_vars()
self.host = 'fake-host.ably.io'
self.ably = await TestApp.get_ably_rest(use_binary_protocol=False, rest_host=self.host)
Expand Down Expand Up @@ -522,8 +525,7 @@ def call_back(request):
name="publish_attempt_route")
self.publish_attempt_route.side_effect = call_back
self.mocked_api.start()

async def asyncTearDown(self):
yield
# We need to have quiet here in order to do not have check if all endpoints were called
self.mocked_api.stop(quiet=True)
self.mocked_api.reset()
Expand Down Expand Up @@ -583,7 +585,8 @@ async def test_when_not_renewable_with_token_details(self):

class TestRenewExpiredToken(BaseAsyncTestCase):

async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.test_vars = await TestApp.get_test_vars()
self.publish_attempts = 0
self.channel = uuid.uuid4().hex
Expand Down Expand Up @@ -629,8 +632,7 @@ def cb_publish(request):

self.publish_message_route.side_effect = cb_publish
self.mocked_api.start()

async def asyncTearDown(self):
yield
self.mocked_api.stop(quiet=True)
self.mocked_api.reset()

Expand Down
6 changes: 3 additions & 3 deletions test/ably/rest/restcapability_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

class TestRestCapability(BaseAsyncTestCase, metaclass=VaryByProtocolTestsMetaclass):

async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.test_vars = await TestApp.get_test_vars()
self.ably = await TestApp.get_ably_rest()

async def asyncTearDown(self):
yield
await self.ably.close()

def per_protocol_setup(self, use_binary_protocol):
Expand Down
6 changes: 3 additions & 3 deletions test/ably/rest/restchannelhistory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

class TestRestChannelHistory(BaseAsyncTestCase, metaclass=VaryByProtocolTestsMetaclass):

async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.ably = await TestApp.get_ably_rest(fallback_hosts=[])
self.test_vars = await TestApp.get_test_vars()

async def asyncTearDown(self):
yield
await self.ably.close()

def per_protocol_setup(self, use_binary_protocol):
Expand Down
12 changes: 6 additions & 6 deletions test/ably/rest/restchannelpublish_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
@pytest.mark.filterwarnings('ignore::DeprecationWarning')
class TestRestChannelPublish(BaseAsyncTestCase, metaclass=VaryByProtocolTestsMetaclass):

async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.test_vars = await TestApp.get_test_vars()
self.ably = await TestApp.get_ably_rest()
self.client_id = uuid.uuid4().hex
self.ably_with_client_id = await TestApp.get_ably_rest(client_id=self.client_id, use_token_auth=True)

async def asyncTearDown(self):
yield
await self.ably.close()
await self.ably_with_client_id.close()

Expand Down Expand Up @@ -450,11 +450,11 @@ async def test_publish_params(self):

class TestRestChannelPublishIdempotent(BaseAsyncTestCase, metaclass=VaryByProtocolTestsMetaclass):

async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.ably = await TestApp.get_ably_rest()
self.ably_idempotent = await TestApp.get_ably_rest(idempotent_rest_publishing=True)

async def asyncTearDown(self):
yield
await self.ably.close()
await self.ably_idempotent.close()

Expand Down
6 changes: 3 additions & 3 deletions test/ably/rest/restchannels_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# makes no request, no need to use different protocols
class TestChannels(BaseAsyncTestCase):

async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.test_vars = await TestApp.get_test_vars()
self.ably = await TestApp.get_ably_rest()

async def asyncTearDown(self):
yield
await self.ably.close()

def test_rest_channels_attr(self):
Expand Down
8 changes: 5 additions & 3 deletions test/ably/rest/restchannelstatus_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging

import pytest

from test.ably.testapp import TestApp
from test.ably.utils import BaseAsyncTestCase, VaryByProtocolTestsMetaclass

Expand All @@ -8,10 +10,10 @@

class TestRestChannelStatus(BaseAsyncTestCase, metaclass=VaryByProtocolTestsMetaclass):

async def asyncSetUp(self):
@pytest.fixture(autouse=True)
async def setup(self):
self.ably = await TestApp.get_ably_rest()

async def asyncTearDown(self):
yield
await self.ably.close()

def per_protocol_setup(self, use_binary_protocol):
Expand Down
Loading
Loading