Skip to content

Commit

Permalink
Skip test if postgres is unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaranvpl committed Jan 24, 2025
1 parent 8058285 commit a3a7b98
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/agentchat/contrib/vectordb/test_pgvectordb.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,17 @@
reason = "do not run on MacOS or windows OR dependency is not installed OR " + reason


def is_postgres_accessible():
try:
conn = psycopg.connect("postgresql://postgres:postgres@localhost:5432/postgres")
conn.close()
return True
except Exception:
return False


@pytest.mark.skipif(
sys.platform in ["darwin", "win32"],
sys.platform in ["darwin", "win32"] or not is_postgres_accessible(),
reason=reason,
)
@skip_on_missing_imports(["pgvector", "psycopg", "sentence_transformers"], "retrievechat-pgvector")
Expand Down

0 comments on commit a3a7b98

Please sign in to comment.