mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Fixed ResourceWarnings in tests (#1366)
* #1320 Update pytest configuration and tests cleanup This commit modifies the pytest's configuration file, `pyproject.toml`, to remove filterwarnings settings. It also makes changes in various test files; the Redis isolation test is now using the provided `redis_storage` fixture instead of setting up its own connection, pytest.mark.filterwarnings is no longer used in `test_isolation.py` and `test_aiohttp_session.py` properly closes off sessions. * Added changelog * Fixed coverage for the RedisEventIsolation
This commit is contained in:
parent
9a2a72fe97
commit
3ad5ed6bc2
5 changed files with 46 additions and 20 deletions
|
|
@ -38,7 +38,7 @@ def pytest_collection_modifyitems(config, items):
|
|||
raise UsageError(f"Invalid redis URI {redis_uri!r}: {e}")
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@pytest.fixture()
|
||||
def redis_server(request):
|
||||
redis_uri = request.config.getoption("--redis")
|
||||
return redis_uri
|
||||
|
|
@ -73,20 +73,9 @@ async def memory_storage():
|
|||
|
||||
@pytest.fixture()
|
||||
@pytest.mark.redis
|
||||
async def redis_isolation(redis_server):
|
||||
if not redis_server:
|
||||
pytest.skip("Redis is not available here")
|
||||
isolation = RedisEventIsolation.from_url(redis_server)
|
||||
try:
|
||||
await isolation.redis.info()
|
||||
except ConnectionError as e:
|
||||
pytest.skip(str(e))
|
||||
try:
|
||||
yield isolation
|
||||
finally:
|
||||
conn = await isolation.redis
|
||||
await conn.flushdb()
|
||||
await isolation.close()
|
||||
async def redis_isolation(redis_storage):
|
||||
isolation = redis_storage.create_isolation()
|
||||
return isolation
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue