Remove redundant pytest.mark.asyncio decorators
- Remove explicit asyncio markers - Clean up unused imports in tests
This commit is contained in:
@@ -170,7 +170,6 @@ class TestQdrantDimensionMismatch:
|
||||
class TestPostgresDimensionMismatch:
|
||||
"""Test suite for PostgreSQL dimension mismatch handling."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_postgres_dimension_mismatch_skip_migration_metadata(self):
|
||||
"""
|
||||
Test that PostgreSQL skips migration when dimensions don't match (via metadata).
|
||||
@@ -220,7 +219,6 @@ class TestPostgresDimensionMismatch:
|
||||
len(insert_calls) == 0
|
||||
), "Migration should be skipped due to dimension mismatch"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_postgres_dimension_mismatch_skip_migration_sampling(self):
|
||||
"""
|
||||
Test that PostgreSQL skips migration when dimensions don't match (via sampling).
|
||||
@@ -277,7 +275,6 @@ class TestPostgresDimensionMismatch:
|
||||
]
|
||||
assert len(insert_calls) == 0, "Migration should be skipped"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_postgres_dimension_match_proceed_migration(self):
|
||||
"""
|
||||
Test that PostgreSQL proceeds with migration when dimensions match.
|
||||
|
||||
@@ -10,7 +10,6 @@ On second startup, Case 1 logic would delete the only table/collection thinking
|
||||
it's "legacy", causing all subsequent operations to fail.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from unittest.mock import MagicMock, AsyncMock, patch
|
||||
|
||||
from lightrag.kg.qdrant_impl import QdrantVectorDBStorage
|
||||
@@ -75,7 +74,6 @@ class TestNoModelSuffixSafety:
|
||||
# because we detected same name
|
||||
assert client.collection_exists.call_count >= 1
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_postgres_no_suffix_second_startup(self):
|
||||
"""
|
||||
Test PostgreSQL doesn't delete table on second startup when no model_name.
|
||||
@@ -176,7 +174,6 @@ class TestNoModelSuffixSafety:
|
||||
collection_name=legacy_collection
|
||||
)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_postgres_with_suffix_case1_still_works(self):
|
||||
"""
|
||||
Test that Case 1 cleanup still works when there IS a suffix.
|
||||
|
||||
@@ -70,7 +70,6 @@ def mock_embedding_func():
|
||||
return func
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_postgres_table_naming(
|
||||
mock_client_manager, mock_pg_db, mock_embedding_func
|
||||
):
|
||||
@@ -96,7 +95,6 @@ async def test_postgres_table_naming(
|
||||
assert storage.legacy_table_name == "LIGHTRAG_VDB_CHUNKS"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_postgres_migration_trigger(
|
||||
mock_client_manager, mock_pg_db, mock_embedding_func
|
||||
):
|
||||
@@ -181,7 +179,6 @@ async def test_postgres_migration_trigger(
|
||||
assert len(migration_executed) > 0, "Migration should have been executed"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_postgres_no_migration_needed(
|
||||
mock_client_manager, mock_pg_db, mock_embedding_func
|
||||
):
|
||||
@@ -214,7 +211,6 @@ async def test_postgres_no_migration_needed(
|
||||
mock_create.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_scenario_1_new_workspace_creation(
|
||||
mock_client_manager, mock_pg_db, mock_embedding_func
|
||||
):
|
||||
@@ -267,7 +263,6 @@ async def test_scenario_1_new_workspace_creation(
|
||||
) # table_name is second positional arg
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_scenario_2_legacy_upgrade_migration(
|
||||
mock_client_manager, mock_pg_db, mock_embedding_func
|
||||
):
|
||||
@@ -385,7 +380,6 @@ async def test_scenario_2_legacy_upgrade_migration(
|
||||
mock_create.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_scenario_3_multi_model_coexistence(
|
||||
mock_client_manager, mock_pg_db, mock_embedding_func
|
||||
):
|
||||
@@ -459,7 +453,6 @@ async def test_scenario_3_multi_model_coexistence(
|
||||
assert storage_b.table_name in table_names
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_case1_empty_legacy_auto_cleanup(
|
||||
mock_client_manager, mock_pg_db, mock_embedding_func
|
||||
):
|
||||
@@ -524,7 +517,6 @@ async def test_case1_empty_legacy_auto_cleanup(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_case1_nonempty_legacy_warning(
|
||||
mock_client_manager, mock_pg_db, mock_embedding_func
|
||||
):
|
||||
@@ -587,7 +579,6 @@ async def test_case1_nonempty_legacy_warning(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_case1_sequential_workspace_migration(
|
||||
mock_client_manager, mock_pg_db, mock_embedding_func
|
||||
):
|
||||
|
||||
@@ -41,7 +41,6 @@ def mock_embedding_func():
|
||||
return func
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_qdrant_collection_naming(mock_qdrant_client, mock_embedding_func):
|
||||
"""Test if collection name is correctly generated with model suffix"""
|
||||
config = {
|
||||
@@ -62,7 +61,6 @@ async def test_qdrant_collection_naming(mock_qdrant_client, mock_embedding_func)
|
||||
assert storage.final_namespace == f"lightrag_vdb_chunks_{expected_suffix}"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_qdrant_migration_trigger(mock_qdrant_client, mock_embedding_func):
|
||||
"""Test if migration logic is triggered correctly"""
|
||||
config = {
|
||||
@@ -141,7 +139,6 @@ async def test_qdrant_migration_trigger(mock_qdrant_client, mock_embedding_func)
|
||||
mock_qdrant_client.create_payload_index.assert_called()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_qdrant_no_migration_needed(mock_qdrant_client, mock_embedding_func):
|
||||
"""Test scenario where new collection already exists (Case 1 in setup_collection)
|
||||
|
||||
@@ -188,7 +185,6 @@ async def test_qdrant_no_migration_needed(mock_qdrant_client, mock_embedding_fun
|
||||
# ============================================================================
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_scenario_1_new_workspace_creation(
|
||||
mock_qdrant_client, mock_embedding_func
|
||||
):
|
||||
@@ -243,7 +239,6 @@ async def test_scenario_1_new_workspace_creation(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_scenario_2_legacy_upgrade_migration(
|
||||
mock_qdrant_client, mock_embedding_func
|
||||
):
|
||||
@@ -353,7 +348,6 @@ async def test_scenario_2_legacy_upgrade_migration(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_scenario_3_multi_model_coexistence(mock_qdrant_client):
|
||||
"""
|
||||
场景3:多模型并存
|
||||
@@ -418,7 +412,6 @@ async def test_scenario_3_multi_model_coexistence(mock_qdrant_client):
|
||||
print(" - Collections are independent")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_case1_empty_legacy_auto_cleanup(mock_qdrant_client, mock_embedding_func):
|
||||
"""
|
||||
Case 1a: 新旧collection都存在,且旧库为空
|
||||
@@ -485,7 +478,6 @@ async def test_case1_empty_legacy_auto_cleanup(mock_qdrant_client, mock_embeddin
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_case1_nonempty_legacy_warning(mock_qdrant_client, mock_embedding_func):
|
||||
"""
|
||||
Case 1b: 新旧collection都存在,且旧库有数据
|
||||
|
||||
@@ -16,8 +16,10 @@ Critical Bug 2: In __aexit__, when async_lock.release() fails, the error
|
||||
recovery logic would attempt to release it again, causing double-release issues.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from unittest.mock import MagicMock, AsyncMock
|
||||
|
||||
import pytest
|
||||
|
||||
from lightrag.kg.shared_storage import (
|
||||
UnifiedLock,
|
||||
get_internal_lock,
|
||||
@@ -65,7 +67,7 @@ class TestUnifiedLockSafety:
|
||||
):
|
||||
get_data_init_lock()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.offline
|
||||
async def test_aexit_no_double_release_on_async_lock_failure(self):
|
||||
"""
|
||||
Test that __aexit__ doesn't attempt to release async_lock twice when it fails.
|
||||
|
||||
@@ -149,7 +149,6 @@ def _assert_no_timeline_overlap(timeline: List[Tuple[str, str]]) -> None:
|
||||
|
||||
|
||||
@pytest.mark.offline
|
||||
@pytest.mark.asyncio
|
||||
async def test_pipeline_status_isolation():
|
||||
"""
|
||||
Test that pipeline status is isolated between different workspaces.
|
||||
@@ -204,7 +203,6 @@ async def test_pipeline_status_isolation():
|
||||
|
||||
|
||||
@pytest.mark.offline
|
||||
@pytest.mark.asyncio
|
||||
async def test_lock_mechanism(stress_test_mode, parallel_workers):
|
||||
"""
|
||||
Test that the new keyed lock mechanism works correctly without deadlocks.
|
||||
@@ -274,7 +272,6 @@ async def test_lock_mechanism(stress_test_mode, parallel_workers):
|
||||
|
||||
|
||||
@pytest.mark.offline
|
||||
@pytest.mark.asyncio
|
||||
async def test_backward_compatibility():
|
||||
"""
|
||||
Test that legacy code without workspace parameter still works correctly.
|
||||
@@ -348,7 +345,6 @@ async def test_backward_compatibility():
|
||||
|
||||
|
||||
@pytest.mark.offline
|
||||
@pytest.mark.asyncio
|
||||
async def test_multi_workspace_concurrency():
|
||||
"""
|
||||
Test that multiple workspaces can operate concurrently without interference.
|
||||
@@ -432,7 +428,6 @@ async def test_multi_workspace_concurrency():
|
||||
|
||||
|
||||
@pytest.mark.offline
|
||||
@pytest.mark.asyncio
|
||||
async def test_namespace_lock_reentrance():
|
||||
"""
|
||||
Test that NamespaceLock prevents re-entrance in the same coroutine
|
||||
@@ -506,7 +501,6 @@ async def test_namespace_lock_reentrance():
|
||||
|
||||
|
||||
@pytest.mark.offline
|
||||
@pytest.mark.asyncio
|
||||
async def test_different_namespace_lock_isolation():
|
||||
"""
|
||||
Test that locks for different namespaces (same workspace) are independent.
|
||||
@@ -546,7 +540,6 @@ async def test_different_namespace_lock_isolation():
|
||||
|
||||
|
||||
@pytest.mark.offline
|
||||
@pytest.mark.asyncio
|
||||
async def test_error_handling():
|
||||
"""
|
||||
Test error handling for invalid workspace configurations.
|
||||
@@ -597,7 +590,6 @@ async def test_error_handling():
|
||||
|
||||
|
||||
@pytest.mark.offline
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_flags_workspace_isolation():
|
||||
"""
|
||||
Test that update flags are properly isolated between workspaces.
|
||||
@@ -727,7 +719,6 @@ async def test_update_flags_workspace_isolation():
|
||||
|
||||
|
||||
@pytest.mark.offline
|
||||
@pytest.mark.asyncio
|
||||
async def test_empty_workspace_standardization():
|
||||
"""
|
||||
Test that empty workspace is properly standardized to "" instead of "_".
|
||||
@@ -781,7 +772,6 @@ async def test_empty_workspace_standardization():
|
||||
|
||||
|
||||
@pytest.mark.offline
|
||||
@pytest.mark.asyncio
|
||||
async def test_json_kv_storage_workspace_isolation(keep_test_artifacts):
|
||||
"""
|
||||
Integration test: Verify JsonKVStorage properly isolates data between workspaces.
|
||||
@@ -961,7 +951,6 @@ async def test_json_kv_storage_workspace_isolation(keep_test_artifacts):
|
||||
|
||||
|
||||
@pytest.mark.offline
|
||||
@pytest.mark.asyncio
|
||||
async def test_lightrag_end_to_end_workspace_isolation(keep_test_artifacts):
|
||||
"""
|
||||
End-to-end test: Create two LightRAG instances with different workspaces,
|
||||
|
||||
@@ -17,7 +17,6 @@ from lightrag.kg.postgres_impl import PGVectorStorage
|
||||
class TestWorkspaceMigrationIsolation:
|
||||
"""Test suite for workspace-scoped migration in PostgreSQL."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_migration_filters_by_workspace(self):
|
||||
"""
|
||||
Test that migration only copies data from the specified workspace.
|
||||
@@ -141,7 +140,6 @@ class TestWorkspaceMigrationIsolation:
|
||||
new_table_record_count["count"] == 2
|
||||
), "Should have migrated 2 records from workspace_a"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_migration_without_workspace_raises_error(self):
|
||||
"""
|
||||
Test that migration without workspace parameter raises ValueError.
|
||||
@@ -162,7 +160,6 @@ class TestWorkspaceMigrationIsolation:
|
||||
base_table="lightrag_doc_chunks",
|
||||
)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_no_cross_workspace_contamination(self):
|
||||
"""
|
||||
Test that workspace B's migration doesn't include workspace A's data.
|
||||
|
||||
Reference in New Issue
Block a user