@@ -22,7 +22,7 @@ def get_antonyms(word):
for syn in wordnet.synsets(word):
for lemma in syn.lemmas():
if lemma.antonyms():
- for antonym in lemma.antonyms:
+ for antonym in lemma.antonyms():
antonyms.append(antonym.name())
return antonyms
@@ -0,0 +1 @@
+["keep_down"]
+[]
+[["Regex", "for", "numbers", "redacted"], ["Regex", "for", "numbers", "phone"], ["Regex", "for", "numbers", "with", "info", "extra"], ["Regex", "for", "numbers", "with", "info", "for", "PlayStation"]]
@@ -0,0 +1,21 @@
+import json
+
+import pytest
+import src.generators.synonym as synonym
[email protected](
+ 'word',
+ [
+ 'dog',
+ 'cat',
+ 'fetcher',
+ 'serializer',
+ 'factory',
+ ]
+)
+def test_antonyms(snapshot, word):
+ result = synonym.get_antonyms(word)
+ snapshot.assert_match(json.dumps(result), 'antonyms')
@@ -1,21 +1,23 @@
import pytest
import spacy
from spacy import displacy
-
from src.generators import Generator
from src.strategies import leaf_strategy
nlp = spacy.load("en_core_web_trf")
@pytest.mark.parametrize('text, expected', [
- ('Regex for redacted phone numbers with extra info for PlayStation', ['PhoneNumberRegex', 'RedactedPhoneNumberRegex'])
+ ('Regex for redacted phone numbers with extra info for PlayStation',
+ ['PhoneNumberRegex', 'RedactedPhoneNumberRegex'])
])
-def test_leaf_strategy(text, expected):
+def test_leaf_strategy(snapshot, text, expected):
generator = Generator(text=text, strategy=leaf_strategy)
results = generator.suggest()
- displacy.serve(docs=[generator.doc])
- doc = generator.doc
- # assert result == expected
+ snapshot.assert_match(json.dumps(results), 'leaf_strategy')
@@ -18,5 +18,4 @@ import src.generators.synonym as synonym
def test_synonyms(snapshot, word):
result = synonym.get_synonyms(word)
- snapshot.snapshot_dir = '__snapshots__' # This line is optional.
- snapshot.assert_match(json.dumps(result), f'test_synonym_{word}.txt')
+ snapshot.assert_match(json.dumps(result), 'synonyms')