Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop pytest asyncio #201

Merged
merged 3 commits into from
Mar 9, 2024
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
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ mkdocs-material==9.5.1

# tests
pytest==7.4.3
pytest-asyncio==0.23.3
types-boto3==1.0.2
types-redis==4.6.0.20240106
anyio==4.1.0
Expand Down
28 changes: 14 additions & 14 deletions tests/_async/test_storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ async def test_s3storage(use_temp_dir, s3):
assert stored_response.content == b"test"


@pytest.mark.asyncio
async def test_redisstorage():
@pytest.mark.parametrize("anyio_backend", ["asyncio"])
async def test_redisstorage(anyio_backend):
if await is_redis_down(): # pragma: no cover
pytest.fail("Redis server was not found")
storage = AsyncRedisStorage()
Expand Down Expand Up @@ -160,8 +160,8 @@ async def test_inmemorystorage():
assert stored_response.content == b"test"


@pytest.mark.asyncio
async def test_filestorage_expired(use_temp_dir):
@pytest.mark.parametrize("anyio_backend", ["asyncio"])
async def test_filestorage_expired(use_temp_dir, anyio_backend):
storage = AsyncFileStorage(ttl=0.2, check_ttl_every=0.1)
first_request = Request(b"GET", "https://example.com")
second_request = Request(b"GET", "https://anotherexample.com")
Expand All @@ -181,8 +181,8 @@ async def test_filestorage_expired(use_temp_dir):
assert await storage.retrieve(first_key) is None


@pytest.mark.asyncio
async def test_s3storage_expired(use_temp_dir, s3):
@pytest.mark.parametrize("anyio_backend", ["asyncio"])
async def test_s3storage_expired(use_temp_dir, s3, anyio_backend):
boto3.client("s3").create_bucket(Bucket="testBucket")
storage = AsyncS3Storage(bucket_name="testBucket", ttl=3)

Expand All @@ -204,8 +204,8 @@ async def test_s3storage_expired(use_temp_dir, s3):
assert await storage.retrieve(first_key) is None


@pytest.mark.asyncio
async def test_filestorage_timer(use_temp_dir):
@pytest.mark.parametrize("anyio_backend", ["asyncio"])
async def test_filestorage_timer(use_temp_dir, anyio_backend):
storage = AsyncFileStorage(ttl=0.2, check_ttl_every=0.2)

first_request = Request(b"GET", "https://example.com")
Expand All @@ -230,8 +230,8 @@ async def test_filestorage_timer(use_temp_dir):
assert await storage.retrieve(second_key) is None


@pytest.mark.asyncio
async def test_redisstorage_expired():
@pytest.mark.parametrize("anyio_backend", ["asyncio"])
async def test_redisstorage_expired(anyio_backend):
if await is_redis_down(): # pragma: no cover
pytest.fail("Redis server was not found")
storage = AsyncRedisStorage(ttl=0.1)
Expand All @@ -253,8 +253,8 @@ async def test_redisstorage_expired():
assert await storage.retrieve(first_key) is None


@pytest.mark.asyncio
async def test_sqlite_expired():
@pytest.mark.parametrize("anyio_backend", ["asyncio"])
async def test_sqlite_expired(anyio_backend):
storage = AsyncSQLiteStorage(ttl=0.1, connection=await anysqlite.connect(":memory:"))
first_request = Request(b"GET", "https://example.com")
second_request = Request(b"GET", "https://anotherexample.com")
Expand All @@ -274,8 +274,8 @@ async def test_sqlite_expired():
assert await storage.retrieve(first_key) is None


@pytest.mark.asyncio
async def test_inmemory_expired():
@pytest.mark.parametrize("anyio_backend", ["asyncio"])
async def test_inmemory_expired(anyio_backend):
storage = AsyncInMemoryStorage(ttl=0.1)
first_request = Request(b"GET", "https://example.com")
second_request = Request(b"GET", "https://anotherexample.com")
Expand Down
14 changes: 7 additions & 7 deletions tests/_sync/test_storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_s3storage(use_temp_dir, s3):



def test_redisstorage():
def test_redisstorage(anyio_backend):
if is_redis_down(): # pragma: no cover
pytest.fail("Redis server was not found")
storage = RedisStorage()
Expand Down Expand Up @@ -161,7 +161,7 @@ def test_inmemorystorage():



def test_filestorage_expired(use_temp_dir):
def test_filestorage_expired(use_temp_dir, anyio_backend):
storage = FileStorage(ttl=0.2, check_ttl_every=0.1)
first_request = Request(b"GET", "https://example.com")
second_request = Request(b"GET", "https://anotherexample.com")
Expand All @@ -182,7 +182,7 @@ def test_filestorage_expired(use_temp_dir):



def test_s3storage_expired(use_temp_dir, s3):
def test_s3storage_expired(use_temp_dir, s3, anyio_backend):
boto3.client("s3").create_bucket(Bucket="testBucket")
storage = S3Storage(bucket_name="testBucket", ttl=3)

Expand All @@ -205,7 +205,7 @@ def test_s3storage_expired(use_temp_dir, s3):



def test_filestorage_timer(use_temp_dir):
def test_filestorage_timer(use_temp_dir, anyio_backend):
storage = FileStorage(ttl=0.2, check_ttl_every=0.2)

first_request = Request(b"GET", "https://example.com")
Expand All @@ -231,7 +231,7 @@ def test_filestorage_timer(use_temp_dir):



def test_redisstorage_expired():
def test_redisstorage_expired(anyio_backend):
if is_redis_down(): # pragma: no cover
pytest.fail("Redis server was not found")
storage = RedisStorage(ttl=0.1)
Expand All @@ -254,7 +254,7 @@ def test_redisstorage_expired():



def test_sqlite_expired():
def test_sqlite_expired(anyio_backend):
storage = SQLiteStorage(ttl=0.1, connection=sqlite3.connect(":memory:"))
first_request = Request(b"GET", "https://example.com")
second_request = Request(b"GET", "https://anotherexample.com")
Expand All @@ -275,7 +275,7 @@ def test_sqlite_expired():



def test_inmemory_expired():
def test_inmemory_expired(anyio_backend):
storage = InMemoryStorage(ttl=0.1)
first_request = Request(b"GET", "https://example.com")
second_request = Request(b"GET", "https://anotherexample.com")
Expand Down
2 changes: 1 addition & 1 deletion unasync.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
("__aenter__", "__enter__"),
("__aexit__", "__exit__"),
("*@pytest.mark.anyio", ""),
("*@pytest.mark.asyncio", ""),
('*@pytest.mark.parametrize\("anyio_backend", \["asyncio"\]\)', ""),
("anysqlite", "sqlite3"),
]
COMPILED_SUBS = [(re.compile(r"(^|\b)" + regex + r"($|\b)"), repl) for regex, repl in SUBS]
Expand Down
Loading