From 324a76d6d291c273403b7b8eec8ff7b0cdd853f5 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 7 Jun 2026 15:50:32 +0200 Subject: [PATCH] test(nlp-service): guard global matcher state in try/finally Co-Authored-By: Claude Sonnet 4.6 --- nlp-service/test_extractor.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/nlp-service/test_extractor.py b/nlp-service/test_extractor.py index ac7490f1..1bf47a9c 100644 --- a/nlp-service/test_extractor.py +++ b/nlp-service/test_extractor.py @@ -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)