def test_component_return():
    """Test that an error is raised if components return a type other than a
    doc."""
    nlp = English()

    @Language.component("test_component_good_pipe")
    def good_pipe(doc):
        return doc

    nlp.add_pipe("test_component_good_pipe")
    nlp("text")
    nlp.remove_pipe("test_component_good_pipe")

    @Language.component("test_component_bad_pipe")
    def bad_pipe(doc):
        return doc.text

    nlp.add_pipe("test_component_bad_pipe")
    with pytest.raises(ValueError, match="instead of a Doc"):
        nlp("text")
Test that an error is raised if components return a type other than a
    doc.
spacy/tests/test_language.py