Skip to content

Commit 0706509

Browse files
cleanup testcontainer implementation
1 parent 8eb3c78 commit 0706509

File tree

3 files changed

+4
-17
lines changed

3 files changed

+4
-17
lines changed

conftest.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
import os
22
import pytest
3-
import asyncio
43

54
from redisvl.redis.connection import RedisConnectionFactory
65
from testcontainers.compose import DockerCompose
76

87

9-
108
@pytest.fixture(scope="session", autouse=True)
119
def redis_container(request):
1210
"""
1311
Create a unique Compose project for each xdist worker by setting
1412
COMPOSE_PROJECT_NAME. That prevents collisions on container/volume names.
1513
"""
16-
# In xdist, the config has "workerid" in workerinput. For the main (non-xdist)
17-
# process, 'workerid' is often 'master' or something similar.
14+
# In xdist, the config has "workerid" in workerinput
1815
worker_id = request.config.workerinput.get("workerid", "master")
1916

2017
# Set the Compose project name so containers do not clash across workers
@@ -26,21 +23,11 @@ def redis_container(request):
2623
compose_file_name="docker-compose.yml",
2724
pull=True,
2825
)
29-
3026
compose.start()
3127

32-
# If you mapped the container port 6379:6379 in docker-compose.yml,
33-
# you might have collisions across workers. If you rely on ephemeral
34-
# host ports, remove the `ports:` block in docker-compose.yml and do:
35-
redis_host, redis_port = compose.get_service_host_and_port("redis", 6379)
36-
#redis_url = f"redis://{redis_host}:{redis_port}"
37-
#os.environ["REDIS_URL"] = redis_url
38-
3928
yield compose
4029

4130
compose.stop()
42-
# Optionally, clean up the COMPOSE_PROJECT_NAME you set:
43-
os.environ.pop("COMPOSE_PROJECT_NAME", None)
4431

4532

4633
@pytest.fixture(scope="session")

scripts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def check_mypy():
2929

3030

3131
def test():
32-
subprocess.run(["python", "-m", "pytest", "-n", "6", "--log-level=CRITICAL"], check=True)
32+
subprocess.run(["python", "-m", "pytest", "-n", "auto", "--log-level=CRITICAL"], check=True)
3333

3434

3535
def test_verbose():

tests/integration/test_vectorizers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def embed(text: str):
8989

9090
@pytest.fixture
9191
def custom_embed_class():
92-
class embedder:
92+
class MyEmbedder:
9393
def embed(self, text: str):
9494
return [1.1, 2.2, 3.3, 4.4]
9595

@@ -105,7 +105,7 @@ def embed_many_with_args(self, texts, param=True):
105105
else:
106106
return [[6.0, 5.0, 4.0], [3.0, 2.0, 1.0]]
107107

108-
return embedder
108+
return MyEmbedder
109109

110110

111111
def test_vectorizer_embed(vectorizer):

0 commit comments

Comments
 (0)