Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7f2e1fc

Browse files
committed
Try using logging instead of print
1 parent 913a91a commit 7f2e1fc

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

tests/conftest.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import logging
12
import os
23
import subprocess
3-
import time
44
from datetime import datetime, timezone
55

66
import pytest
@@ -11,6 +11,8 @@
1111
from redisvl.redis.utils import array_to_buffer
1212
from redisvl.utils.vectorize import HFTextVectorizer
1313

14+
logger = logging.getLogger(__name__)
15+
1416

1517
@pytest.fixture(scope="session")
1618
def worker_id(request):
@@ -94,14 +96,18 @@ def redis_cluster_container(worker_id):
9496
)
9597

9698
if result.returncode != 0:
97-
print(f"Docker Compose up failed with exit code {result.returncode}")
99+
logger.error(f"Docker Compose up failed with exit code {result.returncode}")
98100
if result.stdout:
99-
print(f"STDOUT: {result.stdout.decode('utf-8', errors='replace')}")
101+
logger.error(
102+
f"STDOUT: {result.stdout.decode('utf-8', errors='replace')}"
103+
)
100104
if result.stderr:
101-
print(f"STDERR: {result.stderr.decode('utf-8', errors='replace')}")
105+
logger.error(
106+
f"STDERR: {result.stderr.decode('utf-8', errors='replace')}"
107+
)
102108

103109
# Try to get logs for more details
104-
print("Attempting to fetch container logs...")
110+
logger.info("Attempting to fetch container logs...")
105111
try:
106112
logs_result = subprocess.run(
107113
[
@@ -116,11 +122,11 @@ def redis_cluster_container(worker_id):
116122
capture_output=True,
117123
text=True,
118124
)
119-
print("Docker Compose logs:\n", logs_result.stdout)
125+
logger.info("Docker Compose logs:\n", logs_result.stdout)
120126
if logs_result.stderr:
121-
print("Docker Compose logs stderr:\n", logs_result.stderr)
127+
logger.error("Docker Compose logs stderr:\n", logs_result.stderr)
122128
except Exception as log_e:
123-
print(f"Failed to get Docker Compose logs: {repr(log_e)}")
129+
logger.error(f"Failed to get Docker Compose logs: {repr(log_e)}")
124130

125131
# Now raise the exception with the original result
126132
raise subprocess.CalledProcessError(
@@ -150,7 +156,7 @@ def redis_cluster_container(worker_id):
150156
capture_output=True,
151157
)
152158
except Exception as e:
153-
print(f"Error during cleanup: {repr(e)}")
159+
logger.error(f"Error during cleanup: {repr(e)}")
154160

155161

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

0 commit comments

Comments
 (0)