Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
echo "🔍 Running tests before commit..."

# activate venv if needed
if [ -f ".venv/bin/activate" ]; then
. .venv/bin/activate
fi

pytest tests
STATUS=$?

if [ $STATUS -ne 0 ]; then
echo "❌ Tests failed. Commit aborted."
exit 1
fi

echo "✔️ Tests passed. Proceeding with commit."
exit 0
17 changes: 17 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
echo "🚀 Running tests before push..."

if [ -f ".venv/bin/activate" ]; then
. .venv/bin/activate
fi

pytest
STATUS=$?

if [ $STATUS -ne 0 ]; then
echo "❌ Tests failed. Push aborted."
exit 1
fi

echo "✔️ Tests passed. Proceeding with push."
exit 0
17 changes: 17 additions & 0 deletions tests/test_algorithms.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this supposed to be included in this PR?

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import nltk
import pytest

from tests import df1, df2
Expand All @@ -23,7 +24,23 @@ def test_coma():
# Assume the Schema and instance should provide different results
assert matches_coma_matcher_schema != matches_coma_matcher_instances

def _has_nltk_data():
# Check only what this test actually needs
needed = [
"tokenizers/punkt_tab/english/", # tokenizer
"corpora/wordnet", # wordnet
"corpora/omw-1.4", # multilingual wordnet
"corpora/stopwords", # stopwords
]
for res in needed:
try:
nltk.data.find(res)
except LookupError:
return False
return True


@pytest.mark.skipif(not _has_nltk_data(), reason="Required NLTK data not installed")
def test_cupid():
# Test the CUPID matcher
cu_matcher = Cupid()
Expand Down