From b4b6b125f638fe9ffdc016e8f2e3c166e4b0fdbf Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 16 May 2025 12:55:30 +0200 Subject: [PATCH] Revert "xfail pydantic config tests for now" This reverts commit 2dcedb8aa50ab83a56d24711a1af7cd2df43cf6a. --- spacy/tests/pipeline/test_pipe_factories.py | 8 -------- spacy/tests/pipeline/test_pipe_methods.py | 11 ----------- spacy/tests/serialize/test_serialize_config.py | 5 ----- 3 files changed, 24 deletions(-) diff --git a/spacy/tests/pipeline/test_pipe_factories.py b/spacy/tests/pipeline/test_pipe_factories.py index d85f8c797..c45dccb06 100644 --- a/spacy/tests/pipeline/test_pipe_factories.py +++ b/spacy/tests/pipeline/test_pipe_factories.py @@ -49,8 +49,6 @@ def test_issue5137(): assert nlp2.get_pipe(pipe_name).categories == "my_categories" -# Fails while config validation broken for Pydantic v2 -@pytest.mark.xfail def test_pipe_function_component(): name = "test_component" @@ -114,7 +112,6 @@ def test_pipe_class_component_init(): assert isinstance(pipe.nlp, Language) -@pytest.mark.xfail def test_pipe_class_component_config(): name = "test_class_component_config" @@ -234,7 +231,6 @@ def test_pipe_class_component_model(): assert isinstance(pipe.model, Model) -@pytest.mark.xfail def test_pipe_class_component_model_custom(): name = "test_class_component_model_custom" arch = f"{name}.arch" @@ -279,7 +275,6 @@ def test_pipe_class_component_model_custom(): nlp.add_pipe(name, config=config) -@pytest.mark.xfail def test_pipe_factories_wrong_formats(): with pytest.raises(ValueError): # Decorator is not called @@ -300,7 +295,6 @@ def test_pipe_factories_wrong_formats(): ... -@pytest.mark.xfail def test_pipe_factory_meta_config_cleanup(): """Test that component-specific meta and config entries are represented correctly and cleaned up when pipes are removed, replaced or renamed.""" @@ -342,7 +336,6 @@ def test_pipe_factories_empty_dict_default(): nlp.create_pipe(name) -@pytest.mark.xfail def test_pipe_factories_language_specific(): """Test that language sub-classes can have their own factories, with fallbacks to the base factories.""" @@ -372,7 +365,6 @@ def test_pipe_factories_language_specific(): assert nlp_de.create_pipe(name2)() == "de" -@pytest.mark.xfail def test_language_factories_invalid(): """Test that assigning directly to Language.factories is now invalid and raises a custom error.""" diff --git a/spacy/tests/pipeline/test_pipe_methods.py b/spacy/tests/pipeline/test_pipe_methods.py index b002baa54..4dd7bae16 100644 --- a/spacy/tests/pipeline/test_pipe_methods.py +++ b/spacy/tests/pipeline/test_pipe_methods.py @@ -167,8 +167,6 @@ def test_add_pipe_no_name(nlp): assert "new_pipe" in nlp.pipe_names -# Pydantic validation -@pytest.mark.xfail def test_add_pipe_duplicate_name(nlp): nlp.add_pipe("new_pipe", name="duplicate_name") with pytest.raises(ValueError): @@ -190,8 +188,6 @@ def test_add_pipe_last(nlp, name1, name2): assert nlp.pipeline[-1][0] == name1 -# Pydantic validation -@pytest.mark.xfail def test_cant_add_pipe_first_and_last(nlp): with pytest.raises(ValueError): nlp.add_pipe("new_pipe", first=True, last=True) @@ -205,7 +201,6 @@ def test_get_pipe(nlp, name): assert nlp.get_pipe(name) == new_pipe -@pytest.mark.xfail @pytest.mark.parametrize( "name,replacement,invalid_replacement", [("test_replace_pipe", "other_pipe", lambda doc: doc)], @@ -236,7 +231,6 @@ def test_replace_pipe_config(nlp): assert nlp.get_pipe("entity_linker").incl_prior is False -@pytest.mark.xfail @pytest.mark.parametrize("old_name,new_name", [("old_pipe", "new_pipe")]) def test_rename_pipe(nlp, old_name, new_name): with pytest.raises(ValueError): @@ -246,7 +240,6 @@ def test_rename_pipe(nlp, old_name, new_name): assert nlp.pipeline[0][0] == new_name -@pytest.mark.xfail @pytest.mark.parametrize("name", ["my_component"]) def test_remove_pipe(nlp, name): with pytest.raises(ValueError): @@ -277,7 +270,6 @@ def test_enable_pipes_method(nlp, name): disabled.restore() -@pytest.mark.xfail @pytest.mark.parametrize("name", ["my_component"]) def test_disable_pipes_context(nlp, name): """Test that an enabled component stays enabled after running the context manager.""" @@ -330,7 +322,6 @@ def test_select_pipes_list_arg(nlp): assert not nlp.has_pipe("c3") -@pytest.mark.xfail def test_select_pipes_errors(nlp): for name in ["c1", "c2", "c3"]: nlp.add_pipe("new_pipe", name=name) @@ -362,7 +353,6 @@ def test_add_lots_of_pipes(nlp, n_pipes): assert len(nlp.pipe_names) == n_pipes -@pytest.mark.xfail @pytest.mark.parametrize("component", [lambda doc: doc, {"hello": "world"}]) def test_raise_for_invalid_components(nlp, component): with pytest.raises(ValueError): @@ -539,7 +529,6 @@ def test_pipe_label_data_no_labels(pipe): assert "labels" not in get_arg_names(initialize) -@pytest.mark.xfail def test_warning_pipe_begin_training(): with pytest.warns(UserWarning, match="begin_training"): diff --git a/spacy/tests/serialize/test_serialize_config.py b/spacy/tests/serialize/test_serialize_config.py index 4b9e31f57..b36d3ad74 100644 --- a/spacy/tests/serialize/test_serialize_config.py +++ b/spacy/tests/serialize/test_serialize_config.py @@ -211,8 +211,6 @@ def test_issue8190(): assert nlp.config["custom"]["key"] == "updated_value" -# Pydantic -@pytest.mark.xfail def test_create_nlp_from_config(): config = Config().from_str(nlp_config_string) with pytest.raises(ConfigValidationError): @@ -351,7 +349,6 @@ def test_config_nlp_roundtrip_bytes_disk(): assert new_nlp.config == nlp.config -@pytest.mark.xfail def test_serialize_config_language_specific(): """Test that config serialization works as expected with language-specific factories.""" @@ -387,7 +384,6 @@ def test_serialize_config_language_specific(): load_model_from_config(config) -@pytest.mark.xfail def test_serialize_config_missing_pipes(): config = Config().from_str(nlp_config_string) config["components"].pop("tok2vec") @@ -518,7 +514,6 @@ def test_config_auto_fill_extra_fields(): load_model_from_config(nlp.config) -@pytest.mark.xfail @pytest.mark.parametrize( "parser_config_string", [parser_config_string_upper, parser_config_string_no_upper] )