Skip to content

Commit 51c6866

Browse files
committed
Mark scope for pytests in test_postgres.py
See https://pytest-asyncio.readthedocs.io/en/v0.24.0/reference/markers/ Without this scope, tests cannot connect to pool. Note that in pytest-asyncio 0.24.0, the scope parameter is renamed to "loop_scope", and will need to be updated.
1 parent 7e5f812 commit 51c6866

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

python/tests/integration/connectors/memory/test_postgres.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ def test_create_store(vector_store):
9999
assert vector_store.connection_pool is not None
100100

101101

102-
@pytest.mark.asyncio
102+
@pytest.mark.asyncio(scope="session")
103103
async def test_create_does_collection_exist_and_delete(vector_store: PostgresStore):
104104
suffix = str(uuid.uuid4()).replace("-", "")[:8]
105+
105106
collection = vector_store.get_collection(f"test_collection_{suffix}", SimpleDataModel)
106107

107108
does_exist_1 = await collection.does_collection_exist()
@@ -116,14 +117,14 @@ async def test_create_does_collection_exist_and_delete(vector_store: PostgresSto
116117
assert does_exist_3 is False
117118

118119

119-
@pytest.mark.asyncio
120+
@pytest.mark.asyncio(scope="session")
120121
async def test_list_collection_names(vector_store, simple_collection):
121122
simple_collection_id = simple_collection.collection_name
122123
result = await vector_store.list_collection_names()
123124
assert simple_collection_id in result
124125

125126

126-
@pytest.mark.asyncio
127+
@pytest.mark.asyncio(scope="session")
127128
async def test_upsert_get_and_delete(simple_collection: PostgresCollection):
128129
record = SimpleDataModel(id=1, embedding=[1.1, 2.2, 3.3], data={"key": "value"})
129130

@@ -150,7 +151,7 @@ async def test_upsert_get_and_delete(simple_collection: PostgresCollection):
150151
assert result_after_delete is None
151152

152153

153-
@pytest.mark.asyncio
154+
@pytest.mark.asyncio(scope="session")
154155
async def test_upsert_get_and_delete_pandas(vector_store):
155156
record = SimpleDataModel(id=1, embedding=[1.1, 2.2, 3.3], data={"key": "value"})
156157
definition, df = DataModelPandas(record.model_dump())
@@ -180,7 +181,7 @@ async def test_upsert_get_and_delete_pandas(vector_store):
180181
await collection.delete_collection()
181182

182183

183-
@pytest.mark.asyncio
184+
@pytest.mark.asyncio(scope="session")
184185
async def test_upsert_get_and_delete_batch(simple_collection: VectorStoreRecordCollection):
185186
record1 = SimpleDataModel(id=1, embedding=[1.1, 2.2, 3.3], data={"key": "value"})
186187
record2 = SimpleDataModel(id=2, embedding=[4.4, 5.5, 6.6], data={"key": "value"})

0 commit comments

Comments
 (0)