Skip to content

Commit c404853

Browse files
authored
Add ruff rules for pytest (#563)
1 parent c5f9b9f commit c404853

File tree

21 files changed

+118
-123
lines changed

21 files changed

+118
-123
lines changed

libs/colbert/tests/integration_tests/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ def get_astradb_test_store():
1919
return status["astradb_test_store"]
2020

2121

22-
@pytest.fixture(scope="session", autouse=True)
23-
def before_after_tests():
24-
yield
22+
@pytest.hookimpl()
23+
def pytest_sessionfinish(session, exitstatus):
2524
if (
2625
status["local_cassandra_test_store"]
2726
and status["local_cassandra_test_store"].docker_container

libs/colbert/tests/integration_tests/test_database.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
)
99

1010

11-
@pytest.fixture
11+
@pytest.fixture()
1212
def cassandra():
1313
return get_local_cassandra_test_store()
1414

1515

16-
@pytest.fixture
16+
@pytest.fixture()
1717
def astra_db():
1818
return get_astradb_test_store()
1919

@@ -62,7 +62,7 @@ def test_database_sync(request, vector_store: str):
6262

6363

6464
@pytest.mark.parametrize("vector_store", ["cassandra", "astra_db"])
65-
@pytest.mark.asyncio
65+
@pytest.mark.asyncio()
6666
async def test_database_async(request, vector_store: str):
6767
vector_store = request.getfixturevalue(vector_store)
6868

libs/colbert/tests/integration_tests/test_embedding_retrieval.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
)
1515

1616

17-
@pytest.fixture
17+
@pytest.fixture()
1818
def cassandra():
1919
return get_local_cassandra_test_store()
2020

2121

22-
@pytest.fixture
22+
@pytest.fixture()
2323
def astra_db():
2424
return get_astradb_test_store()
2525

libs/e2e-tests/e2e_tests/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,8 @@ def set_current_test_info(test_name: str, test_info: str):
161161
os.environ["RAGSTACK_E2E_TESTS_TEST_INFO"] = f"{test_name}::{test_info}"
162162

163163

164-
@pytest.fixture(scope="session", autouse=True)
165-
def dump_report():
166-
yield
164+
@pytest.hookimpl()
165+
def pytest_sessionfinish(session, exitstatus):
167166
logging.info("All tests report:")
168167
logging.info("\n".join(all_report_lines))
169168
logging.info("Failed tests report:")

libs/e2e-tests/e2e_tests/langchain/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
)
99

1010

11-
@pytest.fixture
11+
@pytest.fixture()
1212
def astra_db():
1313
handler = get_vector_store_handler(VectorStoreImplementation.ASTRADB)
1414
context = handler.before_test()
1515
yield context
1616
handler.after_test()
1717

1818

19-
@pytest.fixture
19+
@pytest.fixture()
2020
def cassandra():
2121
handler = get_vector_store_handler(VectorStoreImplementation.CASSANDRA)
2222
context = handler.before_test()

libs/e2e-tests/e2e_tests/langchain/test_astra.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def test_vector_search_with_metadata(vectorstore: VectorStore):
402402
assert len(documents) == 0
403403

404404

405-
@pytest.mark.skip
405+
@pytest.mark.skip()
406406
def test_stress_astra():
407407
handler = AstraDBVectorStoreHandler(VectorStoreImplementation.ASTRADB)
408408
while True:
@@ -434,7 +434,7 @@ def embed_query(self, text: str) -> List[float]:
434434
return self.mock_embedding(text)
435435

436436

437-
@pytest.fixture
437+
@pytest.fixture()
438438
def vectorstore() -> AstraDBVectorStore:
439439
if not is_astra:
440440
skip_test_due_to_implementation_not_supported("astradb")

libs/e2e-tests/e2e_tests/langchain/test_compatibility_rag.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141
from e2e_tests.test_utils.vector_store_handler import VectorStoreImplementation
4242

4343

44-
@pytest.fixture
44+
@pytest.fixture()
4545
def astra_db():
4646
handler = get_vector_store_handler(VectorStoreImplementation.ASTRADB)
4747
context = handler.before_test()
4848
yield context
4949
handler.after_test()
5050

5151

52-
@pytest.fixture
52+
@pytest.fixture()
5353
def cassandra():
5454
handler = get_vector_store_handler(VectorStoreImplementation.CASSANDRA)
5555
context = handler.before_test()
@@ -63,19 +63,19 @@ def _chat_openai(**kwargs) -> callable:
6363
)
6464

6565

66-
@pytest.fixture
66+
@pytest.fixture()
6767
def openai_gpt35turbo_llm():
6868
model = "gpt-3.5-turbo"
6969
return {"llm": _chat_openai(model=model, streaming=False), "nemo_config": None}
7070

7171

72-
@pytest.fixture
72+
@pytest.fixture()
7373
def openai_gpt35turbo_llm_streaming():
7474
model = "gpt-3.5-turbo"
7575
return {"llm": _chat_openai(model=model, streaming=True), "nemo_config": None}
7676

7777

78-
@pytest.fixture
78+
@pytest.fixture()
7979
def openai_gpt4_llm():
8080
model = "gpt-4"
8181

@@ -85,7 +85,7 @@ def openai_gpt4_llm():
8585
}
8686

8787

88-
@pytest.fixture
88+
@pytest.fixture()
8989
def openai_gpt4o_llm():
9090
model = "gpt-4o"
9191

@@ -101,22 +101,22 @@ def _openai_embeddings(**kwargs) -> callable:
101101
)
102102

103103

104-
@pytest.fixture
104+
@pytest.fixture()
105105
def openai_ada002_embedding():
106106
return _openai_embeddings(model="text-embedding-ada-002")
107107

108108

109-
@pytest.fixture
109+
@pytest.fixture()
110110
def openai_3small_embedding():
111111
return _openai_embeddings(model="text-embedding-3-small")
112112

113113

114-
@pytest.fixture
114+
@pytest.fixture()
115115
def openai_3large_embedding():
116116
return _openai_embeddings(model="text-embedding-3-large")
117117

118118

119-
@pytest.fixture
119+
@pytest.fixture()
120120
def astra_vectorize_openai_small():
121121
def call():
122122
from astrapy.info import CollectionVectorServiceOptions
@@ -132,7 +132,7 @@ def call():
132132
return call
133133

134134

135-
@pytest.fixture
135+
@pytest.fixture()
136136
def azure_openai_gpt35turbo_llm():
137137
# model is configurable because it can be different from the deployment
138138
# but the targeting model must be gpt-35-turbo
@@ -150,7 +150,7 @@ def llm():
150150
}
151151

152152

153-
@pytest.fixture
153+
@pytest.fixture()
154154
def azure_openai_ada002_embedding():
155155
def embedding():
156156
# model is configurable because it can be different from the deployment
@@ -170,15 +170,15 @@ def embedding():
170170
return embedding
171171

172172

173-
@pytest.fixture
173+
@pytest.fixture()
174174
def vertex_geminipro_llm():
175175
def llm():
176176
return ChatVertexAI(model_name="gemini-pro")
177177

178178
return {"llm": llm, "nemo_config": None}
179179

180180

181-
@pytest.fixture
181+
@pytest.fixture()
182182
def vertex_gecko_embedding() -> callable:
183183
return lambda: VertexAIEmbeddings(model_name="textembedding-gecko")
184184

@@ -189,7 +189,7 @@ def _bedrock_chat(**kwargs) -> callable:
189189
)
190190

191191

192-
@pytest.fixture
192+
@pytest.fixture()
193193
def bedrock_anthropic_claudev2_llm():
194194
return {
195195
"llm": _bedrock_chat(
@@ -199,39 +199,39 @@ def bedrock_anthropic_claudev2_llm():
199199
}
200200

201201

202-
@pytest.fixture
202+
@pytest.fixture()
203203
def bedrock_mistral_mistral7b_llm():
204204
return {
205205
"llm": _bedrock_chat(model_id="mistral.mistral-7b-instruct-v0:2"),
206206
"nemo_config": None,
207207
}
208208

209209

210-
@pytest.fixture
210+
@pytest.fixture()
211211
def bedrock_meta_llama2_llm():
212212
return {
213213
"llm": _bedrock_chat(model_id="meta.llama2-13b-chat-v1"),
214214
"nemo_config": None,
215215
}
216216

217217

218-
@pytest.fixture
218+
@pytest.fixture()
219219
def bedrock_titan_embedding() -> callable:
220220
return lambda: BedrockEmbeddings(
221221
model_id="amazon.titan-embed-text-v1",
222222
region_name=get_required_env("BEDROCK_AWS_REGION"),
223223
)
224224

225225

226-
@pytest.fixture
226+
@pytest.fixture()
227227
def bedrock_cohere_embedding() -> callable:
228228
return lambda: BedrockEmbeddings(
229229
model_id="cohere.embed-english-v3",
230230
region_name=get_required_env("BEDROCK_AWS_REGION"),
231231
)
232232

233233

234-
@pytest.fixture
234+
@pytest.fixture()
235235
def huggingface_hub_flant5xxl_llm():
236236
return {
237237
"llm": lambda: HuggingFaceHub(
@@ -243,15 +243,15 @@ def huggingface_hub_flant5xxl_llm():
243243
}
244244

245245

246-
@pytest.fixture
246+
@pytest.fixture()
247247
def huggingface_hub_minilml6v2_embedding():
248248
return lambda: HuggingFaceInferenceAPIEmbeddings(
249249
api_key=get_required_env("HUGGINGFACE_HUB_KEY"),
250250
model_name="sentence-transformers/all-MiniLM-l6-v2",
251251
)
252252

253253

254-
@pytest.fixture
254+
@pytest.fixture()
255255
def nvidia_aifoundation_embedqa4_embedding():
256256
def embedding():
257257
get_required_env("NVIDIA_API_KEY")
@@ -262,7 +262,7 @@ def embedding():
262262
return embedding
263263

264264

265-
@pytest.fixture
265+
@pytest.fixture()
266266
def nvidia_aifoundation_mixtral8x7b_llm():
267267
def llm():
268268
get_required_env("NVIDIA_API_KEY")
@@ -284,7 +284,7 @@ def llm():
284284
["astra_db", "cassandra"],
285285
)
286286
@pytest.mark.parametrize(
287-
"embedding,llm",
287+
("embedding", "llm"),
288288
[
289289
("openai_ada002_embedding", "openai_gpt35turbo_llm"),
290290
("openai_3large_embedding", "openai_gpt35turbo_llm_streaming"),
@@ -364,29 +364,29 @@ def _run_test(
364364
raise ValueError(f"Unknown test case: {test_case}")
365365

366366

367-
@pytest.fixture
367+
@pytest.fixture()
368368
def vertex_gemini_multimodal_embedding():
369369
return MultiModalEmbeddingModel.from_pretrained("multimodalembedding@001"), 1408
370370

371371

372-
@pytest.fixture
372+
@pytest.fixture()
373373
def vertex_gemini_pro_vision_llm():
374374
return ChatVertexAI(model_name="gemini-pro-vision")
375375

376376

377-
@pytest.fixture
377+
@pytest.fixture()
378378
def vertex_gemini_pro_llm():
379379
return ChatVertexAI(model_name="gemini-pro")
380380

381381

382-
@pytest.fixture
382+
@pytest.fixture()
383383
def gemini_pro_vision_llm():
384384
return ChatGoogleGenerativeAI(
385385
model="gemini-pro-vision", google_api_key=get_required_env("GOOGLE_API_KEY")
386386
)
387387

388388

389-
@pytest.fixture
389+
@pytest.fixture()
390390
def gemini_pro_llm():
391391
return ChatGoogleGenerativeAI(
392392
model="gemini-pro", google_api_key=get_required_env("GOOGLE_API_KEY")
@@ -398,7 +398,7 @@ def gemini_pro_llm():
398398
["astra_db", "cassandra"],
399399
)
400400
@pytest.mark.parametrize(
401-
"embedding,llm",
401+
("embedding", "llm"),
402402
[
403403
# disable due to this bug:
404404
# https://github.com/googleapis/python-aiplatform/issues/3227

libs/e2e-tests/e2e_tests/langchain_llamaindex/test_astra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def test_ingest_langchain_retrieve_llama_index(astra_ref: AstraRef):
219219
assert "framework" in response.response
220220

221221

222-
@pytest.fixture
222+
@pytest.fixture()
223223
def astra_ref() -> AstraRef:
224224
if not is_astra:
225225
skip_test_due_to_implementation_not_supported("astradb")

libs/e2e-tests/e2e_tests/llama_index/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
)
99

1010

11-
@pytest.fixture
11+
@pytest.fixture()
1212
def astra_db():
1313
handler = get_vector_store_handler(VectorStoreImplementation.ASTRADB)
1414
context = handler.before_test()
1515
yield context
1616
handler.after_test()
1717

1818

19-
@pytest.fixture
19+
@pytest.fixture()
2020
def cassandra():
2121
handler = get_vector_store_handler(VectorStoreImplementation.CASSANDRA)
2222
context = handler.before_test()

libs/e2e-tests/e2e_tests/llama_index/test_astra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def test_vector_search_with_metadata(environment: Environment):
201201
# assert len(documents) == 0
202202

203203

204-
@pytest.fixture
204+
@pytest.fixture()
205205
def environment() -> Environment:
206206
if not is_astra:
207207
skip_test_due_to_implementation_not_supported("astradb")

0 commit comments

Comments
 (0)