mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-24 17:06:29 +03:00
Ensure match pattern error isn't raised on empty errors (closes #3549)
This commit is contained in:
parent
3ddb799f27
commit
4d198a7e92
|
@ -105,7 +105,7 @@ cdef class Matcher:
|
|||
raise ValueError(Errors.E012.format(key=key))
|
||||
if self.validator:
|
||||
errors[i] = validate_json(pattern, self.validator)
|
||||
if errors:
|
||||
if any(err for err in errors.values()):
|
||||
raise MatchPatternError(key, errors)
|
||||
key = self._normalize_key(key)
|
||||
for pattern in patterns:
|
||||
|
|
15
spacy/tests/regression/test_issue3549.py
Normal file
15
spacy/tests/regression/test_issue3549.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
# coding: utf8
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import pytest
|
||||
from spacy.matcher import Matcher
|
||||
from spacy.errors import MatchPatternError
|
||||
|
||||
|
||||
def test_issue3549(en_vocab):
|
||||
"""Test that match pattern validation doesn't raise on empty errors."""
|
||||
matcher = Matcher(en_vocab, validate=True)
|
||||
pattern = [{"LOWER": "hello"}, {"LOWER": "world"}]
|
||||
matcher.add("GOOD", None, pattern)
|
||||
with pytest.raises(MatchPatternError):
|
||||
matcher.add("BAD", None, [{"X": "Y"}])
|
Loading…
Reference in New Issue
Block a user