Skip to content

Commit

Permalink
Log tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
bakar-io committed Apr 22, 2024
1 parent e134f14 commit 2410f9a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ migrate:

test:
# We need to update handling of env variables for tests
STORAGE_TYPE=postgres YDC_API_KEY=placeholder OPENAI_API_KEY=placeholder poetry run pytest $(TEST_FILE)
STORAGE_TYPE=postgres YDC_API_KEY=placeholder OPENAI_API_KEY=placeholder poetry run pytest -s $(TEST_FILE)


test_watch:
Expand Down
12 changes: 8 additions & 4 deletions backend/tests/unit_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
import asyncio
import logging
import os
import subprocess

Expand Down Expand Up @@ -60,8 +60,10 @@ async def _drop_test_db() -> None:
def _migrate_test_db() -> None:
logger.info("Migrating test database")
# Run subprocess and capture output and errors
result = subprocess.run(["make", "migrate"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)

result = subprocess.run(
["make", "migrate"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
)

# Log standard output and errors
if result.stdout:
logger.info("Subprocess output: %s", result.stdout)
Expand All @@ -71,7 +73,9 @@ def _migrate_test_db() -> None:
# Check if the subprocess exited with a non-zero exit code
if result.returncode != 0:
logger.error("Subprocess failed with return code %s", result.returncode)
raise subprocess.CalledProcessError(result.returncode, result.args, output=result.stdout, stderr=result.stderr)
raise subprocess.CalledProcessError(
result.returncode, result.args, output=result.stdout, stderr=result.stderr
)


@pytest.fixture(scope="session")
Expand Down

0 comments on commit 2410f9a

Please sign in to comment.