From 725026bfefe78f9009e09dca4b84892bce425da8 Mon Sep 17 00:00:00 2001 From: Stefano Lottini Date: Fri, 22 Sep 2023 04:22:23 +0200 Subject: [PATCH] linter/typechecker-friendly improvements to cassandra test (#7771) --- tests/vector_stores/test_cassandra.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/vector_stores/test_cassandra.py b/tests/vector_stores/test_cassandra.py index 3074e24556855..aaf787734cd84 100644 --- a/tests/vector_stores/test_cassandra.py +++ b/tests/vector_stores/test_cassandra.py @@ -10,17 +10,19 @@ from llama_index.vector_stores.cassandra import CassandraVectorStore try: - import cassio + import cassio # noqa: F401 + + has_cassio = True except ImportError: - cassio = None + has_cassio = False class TestCassandraVectorStore(unittest.TestCase): - @pytest.mark.skipif(cassio is None, reason="cassio not installed") + @pytest.mark.skipif(not has_cassio, reason="cassio not installed") def test_cassandra_create_and_crud(self) -> None: mock_db_session = MagicMock() try: - import cassio # noqa: F401 + import cassio # noqa: F401, F811 except ModuleNotFoundError: # mock `cassio` if not installed mock_cassio = MagicMock() @@ -51,11 +53,11 @@ def test_cassandra_create_and_crud(self) -> None: vector_store.client - @pytest.mark.skipif(cassio is None, reason="cassio not installed") + @pytest.mark.skipif(not has_cassio, reason="cassio not installed") def test_cassandra_queries(self) -> None: mock_db_session = MagicMock() try: - import cassio # noqa: F401 + import cassio # noqa: F401, F811 except ModuleNotFoundError: # mock `cassio` if not installed mock_cassio = MagicMock()