Skip to content

Commit c5c85e6

Browse files
committed
3.13 test
1 parent 89b04b9 commit c5c85e6

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

xinference/model/embedding/tests/test_embedding_models.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import os
1717
import shutil
1818
import tempfile
19-
import warnings
2019

2120
import pytest
2221

@@ -303,7 +302,8 @@ def custom_warning_handler(
303302
# Restore original warning handler
304303
warnings.showwarning = old_showwarning
305304

306-
# Now run with pytest.warns to capture the official warningswith pytest.warns(UserWarning) as record:
305+
# Now run with pytest.warns to capture the official warnings
306+
with pytest.warns(UserWarning) as record:
307307
_install()
308308
print(f"DEBUG: pytest.warns captured {len(record)} warnings")
309309
for i, warning in enumerate(record):
@@ -318,8 +318,8 @@ def custom_warning_handler(
318318
print(f"DEBUG: Checking warning message: {message}")
319319
if (
320320
"has error" in message
321-
and(
322-
"Invalid model URI " in message
321+
and (
322+
"Invalid model URI " in message
323323
or "Model URI cannot be a relative path" in message
324324
)
325325
and "/new_data/cache/gte-Qwen2" in message
@@ -330,23 +330,22 @@ def custom_warning_handler(
330330

331331
assert (
332332
found_warning
333-
), f"Expected warning about invalid model URI not found. Warnings: {[str(w.message)
334-
for w in record]}"
335-
finally:
333+
), f"Expected warning about invalid model URI not found. Warnings: {[str(w.message) for w in record]}"
334+
336335
# Restore original warning handler
337336
warnings.showwarning = old_showwarning
338337

338+
finally:
339+
# Restore original warning handler in case of any exceptions
340+
warnings.showwarning = old_showwarning
341+
339342
# Debug: Check if file still exists after test
340343
print(f"DEBUG: File exists after test: {os.path.exists(file_path)}")
341344

342345
# Clean up
343346
if os.path.exists(file_path):
344347
os.remove(file_path)
345348
print("DEBUG: Test file cleaned up")
346-
finally:
347-
# Clean up the test file to avoid interference with subsequent test runs
348-
if os.path.exists(file_path):
349-
os.remove(file_path)
350349

351350

352351
def test_convert_ids_to_tokens():

0 commit comments

Comments
 (0)