Fail redis and mongo tests if incorrect URI

If incorrect URIs provided to "--redis" and/or "--mongo" options
tests should fail with ERRORs instead of skipping.
Otherwise the next scenario is possible:
  1) developer breaks RedisStorage and/or MongoStorage code
  2) tests are run with incorrect redis and/or mongo URIs
     provided by "--redis" and "--mongo" options.
     For example, wrong port specified.
  3) tests pass because skipping doesn't fail tests run
  4) developer or reviewer doesn't notice
     that redis and/or mongo tests were skipped
  5) broken code gets in codebase
This commit is contained in:
Rishat Fayzullin 2024-06-13 13:16:57 +03:00
parent 15106f62df
commit 8837f1767c

View file

@ -54,7 +54,7 @@ async def redis_storage(redis_server):
try:
await storage.redis.info()
except ConnectionError as e:
pytest.skip(str(e))
pytest.fail(str(e))
try:
yield storage
finally:
@ -85,7 +85,7 @@ async def mongo_storage(mongo_server):
try:
await storage._client.server_info()
except PyMongoError as e:
pytest.skip(str(e))
pytest.fail(str(e))
else:
yield storage
await storage._client.drop_database(storage._database)