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
|
||||
assert len(r.personNames) >= 1
|
||||
|
||||
def test_empty_matcher_returns_no_persons(self):
|
||||
# Temporarily use an empty matcher
|
||||
from extractor import set_person_matcher
|
||||
empty = PersonMatcher()
|
||||
set_person_matcher(empty)
|
||||
r = extract("Briefe von Clara Cram", "de")
|
||||
assert r.personNames == []
|
||||
# Restore seeded matcher
|
||||
m = PersonMatcher()
|
||||
m.load(_TEST_PERSONS)
|
||||
set_person_matcher(m)
|
||||
def test_empty_matcher_returns_no_persons(self, seeded_matcher):
|
||||
from extractor import get_person_matcher, set_person_matcher
|
||||
original = get_person_matcher()
|
||||
try:
|
||||
set_person_matcher(PersonMatcher())
|
||||
r = extract("Briefe von Clara Cram", "de")
|
||||
assert r.personNames == []
|
||||
finally:
|
||||
set_person_matcher(original)
|
||||
|
||||
Reference in New Issue
Block a user