test_leaf_strategy.py 660 B

1234567891011121314151617181920212223242526
  1. import json
  2. import pytest
  3. import spacy
  4. from word_processor.generators import Generator
  5. from word_processor.strategies import leaf_strategy
  6. nlp = spacy.load("en_core_web_trf")
  7. @pytest.mark.parametrize('text, expected', [
  8. ('Regex for redacted phone numbers with extra info for PlayStation',
  9. ['PhoneNumberRegex', 'RedactedPhoneNumberRegex'])
  10. ])
  11. def test_leaf_strategy(snapshot, text, expected):
  12. generator = Generator(text=text, strategy=leaf_strategy)
  13. results = generator.suggest()
  14. text_results = []
  15. for suggestion in results:
  16. text_results.append([token.text for token in suggestion])
  17. assert text_results == snapshot