test(nlp-service): guard global matcher state in try/finally
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -324,14 +324,12 @@ class TestExtract:
|
|||||||
# Should still find persons despite lowercase
|
# Should still find persons despite lowercase
|
||||||
assert len(r.personNames) >= 1
|
assert len(r.personNames) >= 1
|
||||||
|
|
||||||
def test_empty_matcher_returns_no_persons(self):
|
def test_empty_matcher_returns_no_persons(self, seeded_matcher):
|
||||||
# Temporarily use an empty matcher
|
from extractor import get_person_matcher, set_person_matcher
|
||||||
from extractor import set_person_matcher
|
original = get_person_matcher()
|
||||||
empty = PersonMatcher()
|
try:
|
||||||
set_person_matcher(empty)
|
set_person_matcher(PersonMatcher())
|
||||||
r = extract("Briefe von Clara Cram", "de")
|
r = extract("Briefe von Clara Cram", "de")
|
||||||
assert r.personNames == []
|
assert r.personNames == []
|
||||||
# Restore seeded matcher
|
finally:
|
||||||
m = PersonMatcher()
|
set_person_matcher(original)
|
||||||
m.load(_TEST_PERSONS)
|
|
||||||
set_person_matcher(m)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user