def test_textcat_legacy_scorers(component_name, scorer):
    """Check that legacy scorers are registered and produce the expected score
    keys."""
    nlp = English()
    nlp.add_pipe(component_name, config={"scorer": {"@scorers": scorer}})

    train_examples = []
    for text, annotations in TRAIN_DATA_SINGLE_LABEL:
        train_examples.append(Example.from_dict(nlp.make_doc(text), annotations))
    nlp.initialize(get_examples=lambda: train_examples)

    # score the model (it's not actually trained but that doesn't matter)
    scores = nlp.evaluate(train_examples)
    assert 0 <= scores["cats_score"] <= 1
Check that legacy scorers are registered and produce the expected score
    keys.
spacy/tests/pipeline/test_textcat.py