Pārlūkot izejas kodu

move tests around

Nikos Atlas 2 gadi atpakaļ
vecāks
revīzija
6d0fb2c063

+ 1 - 1
src/generators/synonym.py

@@ -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

+ 1 - 0
src/tests/snapshots/test_antonyms/test_antonyms/cat/antonyms

@@ -0,0 +1 @@
+["keep_down"]

+ 0 - 0
__snapshots__/test_synonym_fetcher.txt → src/tests/snapshots/test_antonyms/test_antonyms/dog/antonyms


+ 0 - 0
__snapshots__/test_synonym_serializer.txt → src/tests/snapshots/test_antonyms/test_antonyms/factory/antonyms


+ 1 - 0
src/tests/snapshots/test_antonyms/test_antonyms/fetcher/antonyms

@@ -0,0 +1 @@
+[]

+ 1 - 0
src/tests/snapshots/test_antonyms/test_antonyms/serializer/antonyms

@@ -0,0 +1 @@
+[]

+ 1 - 0
src/tests/snapshots/test_leaf_strategy/test_leaf_strategy/Regex_for_redacted_phone_numbers_with_extra_info_for_PlayStation-expected0/leaf_strategy

@@ -0,0 +1 @@
+[["Regex", "for", "numbers", "redacted"], ["Regex", "for", "numbers", "phone"], ["Regex", "for", "numbers", "with", "info", "extra"], ["Regex", "for", "numbers", "with", "info", "for", "PlayStation"]]

+ 0 - 0
__snapshots__/test_synonym_cat.txt → src/tests/snapshots/test_synonyms/test_synonyms/cat/synonyms


+ 0 - 0
__snapshots__/test_synonym_dog.txt → src/tests/snapshots/test_synonyms/test_synonyms/dog/synonyms


+ 0 - 0
__snapshots__/test_synonym_factory.txt → src/tests/snapshots/test_synonyms/test_synonyms/factory/synonyms


+ 1 - 0
src/tests/snapshots/test_synonyms/test_synonyms/fetcher/synonyms

@@ -0,0 +1 @@
+[]

+ 1 - 0
src/tests/snapshots/test_synonyms/test_synonyms/serializer/synonyms

@@ -0,0 +1 @@
+[]

+ 21 - 0
src/tests/test_antonyms.py

@@ -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')

+ 8 - 6
src/tests/test_leaf_strategy.py

@@ -1,21 +1,23 @@
+import json
+
 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')

+ 1 - 2
src/tests/test_synonyms.py

@@ -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')